Last active
August 29, 2015 14:20
-
-
Save tjvr/098d4b4c7221c7d1c2f4 to your computer and use it in GitHub Desktop.
Things in boxes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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));; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Failed attempt at arranging 5 things into 4 boxes
Call with
arrange 5 boxes