Skip to content

Instantly share code, notes, and snippets.

@briantrice
Created September 18, 2012 03:34
Show Gist options
  • Save briantrice/3741095 to your computer and use it in GitHub Desktop.
Save briantrice/3741095 to your computer and use it in GitHub Desktop.
A stupid-simple cross-product for collections
collections define: #CrossProduct &slots: {#rows -> #{}. #columns -> #{}}.
c@(Collection traits) <*> d@(Collection traits)
[
CrossProduct new `>> [rows := c. columns := d. ]
].
cross@(CrossProduct traits) do: block
[
c do: [| :a |
d do: [| :b |
block apply*, a, b]]
].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment