Comment detail

全ての組み合わせ (Nested Flatten)

	
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
function cp(lists){
  if (size(lists) == 1){
    yield project(lists[0], {_x->{_x}})
  } else {
    for (r : cp(lists[1..])){
      for (m:r){
        for (a:project(lists[0], {e-> {e}+ m})) yield {a}
      }
    }
  }
}
function listcp(lists) list(project(cp(lists), {x->x[0]}))

println(listcp([[1,2,3,4], "abc"]))

Index

Feed

Other

Link

Pathtraq

loading...