Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % transpose/2
- transpose([[]|_], []).
- transpose(I, [O|Os]) :- transpose(I, O, R), transpose(R, Os).
- % transpose/3
- transpose([], [], []).
- transpose([[L|Ls]|I], [L|O], [Ls|R]) :- transpose(I, O, R).
- % /3 peels off the leftmost column and returns the two pieces
- % i.e. [[1,2,3],[4,5,6],[7,8,9]] -> [1,4,7] and [[2,3],[5,6],[8,9]]
- % /2 makes a list of the peels from /3
Advertisement
Add Comment
Please, Sign In to add comment