I’m using: SWI-Prolog version 8.4.3 for x64-win64
I want the code to print elements of the list with them indexes
Exemple :
from this list :
[p(301, 1, 2), p(201, 5, 2), p(401, 1, 4), p(501, 1, 5)]
I want to get something like :
1 301 1 2
2 201 5 2
3 401 1 4
4 501 1 5
My code looks like this:
forall(order_by([asc(Z)], p(X,Y,Z)), format("~w ~w ~w~n", [X,Y,Z])).
Thanks to @Boris who helped me with the format
But, how can i add the index in each line ?