Comment detail
全ての組み合わせ (Nested Flatten)ether さんの #2152 の簡潔さに感心しつつ、それをヒントにして同様のことを Squeak Smalltalk で。
1 2 3 4 | | input |
input := #((0 1) 'ab' (foo bar)).
^input reversed inject: #(()) into: [:arrs :colln |
colln inject: #() into: [:rs :elem | rs, (arrs collect: [:arr | {elem}, arr])]]
|





sumim
#2153()
[
Smalltalk
]
Rating0/0=0.00
| input results gen | input := #((0 1) 'ab' (Foo Bar)). results := OrderedCollection new. gen := input reversed inject: [:arr | results add: arr] into: [:block :colln | [:arr | colln do: [:ea | block value: arr, {ea}]] fixTemps]. gen value: #(). ^results asArray "=> #((0 $a Foo) (0 $a Bar) (0 $b Foo) (0 $b Bar) (1 $a Foo) (1 $a Bar) (1 $b Foo) (1 $b Bar)) "Rating0/0=0.00-0+
1 reply [ reply ]