I worked all afternoon on a simple thing but cannot seem to get it right for some reason : how to turn a list into a matrix of given width.
Example : I got a list such a
BTW, I thought I'd mention the code I finally wrote :
length_(Length, List) :- length(List, Length).
list2matrix(List, RowSize, Matrix) :-
length(List, L),
HowManyRows is L div RowSize,
length(Matrix, HowManyRows),
maplist(length_(RowSize), Matrix),
append(Matrix, List).
It's more high order oriented and funnier to read I guess :)