Fil-C on Nix

Filnix wiki

mbrock/filnix/nanofil

list_partition.pl

Stable list partitioning shared by promotion and register selection. Trealla's library(lists) supplies include/3 and exclude/3, but not SWI's partition/4. Evaluate the predicate only once per element.

modulelist_partition
5:- meta_predicatepartition1, ?, ?, ?
partition:Predicate, +List, -Included, -Excludeddet

Included and Excluded retain List's order. Each element goes into Included if Predicate succeeds once, and into Excluded otherwise.

11partition_, [], [], []
12partitionP, X|Xs, In, Out ←
callP, X
→
In = X|Ins
Out = Outs
else
In = Ins
Out = X|Outs
partitionP, Xs, Ins, Outs