s-webber / projog

Prolog programming for the Java platform.
Apache License 2.0
37 stars 9 forks source link

add pairs_keys/2 and pairs_values/2 #212

Closed s-webber closed 2 years ago

s-webber commented 2 years ago
  1. Add pairs_keys/2 built-in predicate. Unifies its second argument with a list of keys obtained from the list of Key-Value pairs provided as its first argument. e.g.:
?- pairs_keys([a-y, c-x, b-z], L)
L = [a,c,b]

?- pairs_keys([a-y, a-x, a-z], L)
L = [a,a,a]
  1. Add pairs_values/2 built-in predicate. Unifies its second argument with a list of values obtained from the list of Key-Value pairs provided as its first argument. e.g.:
?- pairs_values([a-y, c-x, b-z], L)
L = [y,x,z]

?- pairs_values([a-y, c-y, b-y], L)
L = [y,y,y]