2

I have a list

L = [-n,-b,-s]

How do i get a list with

L = [n,b,s]

Is there a built in predicate to do this?.

repeat
  • 18,496
  • 4
  • 54
  • 166
Krishna Kalyan
  • 1,672
  • 2
  • 20
  • 43

1 Answers1

1

Yes! maplist/3 can handle the recursive part for you, but you have to customize it by declaring what the mapping of a single list element should be like.

minus_stripped(-X, X).

Sample query:

?- maplist(minus_stripped, [-n,-b,-s], Xs).
Xs = [n,b,s].
Community
  • 1
  • 1
repeat
  • 18,496
  • 4
  • 54
  • 166