-- grp fn xs: group list items by the key returned by `fn`.
-- Result is a map from key to the sublist of items that produced it.
-- Signature: grp fn:F a k xs:L a > M k (L a)
-- Key function: parity as a string (so the resulting map has string keys).
par n:n>t;r=mod n 2;str r
by-parity ns:L n>M t (L n);grp par ns
-- engine-skip: jit
-- run: by-parity [1,2,3,4,5,6]
-- out: {0: [2, 4, 6]; 1: [1, 3, 5]}