-1

How can i display a list :

Sorted = [p(201, 15, 2), p(301, 15, 3), p(401, 30, 4), p(501, 75, 5)].

in this format:

201 15 2
301 15 3
401 30 4
501 75 5

i used display(Sorted), is there any other function to solve this ?

elfii
  • 49
  • 7
  • Also discussed at https://swi-prolog.discourse.group/t/sorting-predicates-in-prolog/5618 – brebs Jul 25 '22 at 10:32

1 Answers1

0
forall(member(p(X, Y, Z), Sorted), format('~w ~w ~w~n', [X, Y, Z])).

Result in swi-prolog:

201 15 2
301 15 3
401 30 4
501 75 5
brebs
  • 3,462
  • 2
  • 3
  • 12