N
N
nazarovdaniil2014-03-06 13:52:55
Prolog
nazarovdaniil, 2014-03-06 13:52:55

Prolog SWI - how to reverse the order of elements in a list?

Prolog SWI. There is a list L1, the elements of which are lists L, it is necessary to reverse the order of the elements in the lists L, and then replace the order of the lists L in the list L1 with the reverse.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Vasiliev, 2014-03-20
@vvladimirs

If I understand correctly, then:

p(L, R):-
  maplist(reverse, L, RL),
  reverse(RL, R).

Call like this:
?- p(, X).
X = .

?- p(, X).
X = .                                                                                 
                                                                                                                         
?-

N
nazarovdaniil, 2014-03-20
@nazarovdaniil

Thanks, but I already found the solution

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question