1

I've asked around how to construct a list with the facts ordered by a specific character inside it and the solution given was a KEY-Value return. Like for instance :

1-package(N,3,1).

However what I truly need is to access the variable in the position N. I've tried separating the key from the fact with [K-H|T], H giving me package(N,3,1), but how do I access N?

coder
  • 12,832
  • 5
  • 39
  • 53
E.T.
  • 367
  • 5
  • 18

1 Answers1

1

Simply write H=package(N,3,1) to unify H with term package(N,3,1) and instead of returning H in the parameters return N.

Another way doing this is directly write: [K-package(N,3,1)|T] instead of [K-H|T] and return N.

coder
  • 12,832
  • 5
  • 39
  • 53
  • I am a bit stupid, I thought of [K-package(N,3,1)|T] before but for some reason at compilation it kept getting an error. Tried it now and it worked, guess it was something else that was up with the code. Thank you. – E.T. Dec 13 '16 at 15:03
  • Glad that helped!! – coder Dec 13 '16 at 15:40