Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun {GenerateRows N Cs}
- case Cs
- of nil then [{Replicate N 0}]
- [] C|Cr then
- if N < C then nil
- else
- local W B in
- W = {AppendToAll 0 {GenerateRows N-1 Cs}}
- case Cr
- of nil then B = [{Append {Replicate C 1} {Replicate N-C 0}}]
- else B = {AppendToAll {Replicate C 1} {AppendToAll 0 {GenerateRows N-C-1 Cr}}}
- end
- {Append W B}
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement