So, if one considers pairs to as Key-Value
, then
Function is a predicate of arity 2: Function(Value,Key)
For example for predicate length/2, on can read it as
length(ListAsValue,LengthAsKey)
:
Hence the example:
?- map_list_to_pairs(length, [[a,b],[],[c,d,e],[f,g,h,i]], Pairs). Pairs = [2-[a, b], 0-[], 3-[c, d, e], 4-[f, g, h, i]].