forked from x/ContextOS
opt some
This commit is contained in:
parent
b19fc4fc58
commit
7ff38a4575
4
src/hi/sku.go
Normal file
4
src/hi/sku.go
Normal file
@ -0,0 +1,4 @@
|
||||
package hi
|
||||
|
||||
func init() {
|
||||
}
|
25
src/sku.go
Normal file
25
src/sku.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func helper(chunks [][]string, chunkIndex int, prev []string, res [][]string) [][]string {
|
||||
chunk := chunks[chunkIndex]
|
||||
isLast := chunkIndex == len(chunks)-1
|
||||
for _, val := range chunk {
|
||||
if cur := append(prev, val); isLast {
|
||||
res = append(res, cur)
|
||||
} else {
|
||||
res = helper(chunks, chunkIndex+1, cur, res)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
func combine(chunks ...[]string) (res [][]string) {
|
||||
return helper(chunks, 0, []string{}, res)
|
||||
}
|
||||
func main() {
|
||||
names := []string{"iPhone X", "iPhone XS"}
|
||||
colors := []string{"黑色", "白色"}
|
||||
storage := []string{"64g", "256g"}
|
||||
fmt.Println(combine(names, colors, storage))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user