Skip to content

Instantly share code, notes, and snippets.

@tjvr
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjvr/098d4b4c7221c7d1c2f4 to your computer and use it in GitHub Desktop.
Save tjvr/098d4b4c7221c7d1c2f4 to your computer and use it in GitHub Desktop.
Things in boxes
fun boxes = [0, 0, 0, 0];;
fun allcons x [] = []
| allcons x (l :: ll) =
(x :: l) :: (allcons x ll) ;;
fun arrange 0 l = [l]
| arrange n [] = []
| arrange n (x::l) =
(arrange (n-1) ((x+1) :: l)) @ (allcons x (arrange n l));;
@tjvr
Copy link
Author

tjvr commented May 3, 2015

Failed attempt at arranging 5 things into 4 boxes

Call with arrange 5 boxes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment