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 as
[1, 3, 5, 7, 6, 8, 9, 0]
and want to create a matrix such as
[[1, 3],
[5, 7],
[6, 8],
[9, 0]]
through a predicate
list2matrix/3 : list2matrix(List, Size_of_Rows, Matrix).
In this example used like :
list2matrix([1, 3, 5, 7, 6, 8, 9, 0], 2, Matrix).
The predicate should fail if the length of the list is not a multiple of the size of the rows.
I decided not to post my work since I think I got it so wrong that it would not help me to get correction on it ;(
Thanks by advance if you can propose any leads about how to deal with such a problem.