Skip to content

Commit cca32af

Browse files
Introduce mem-rel! function in builtin_stdlib.elpi
The motivation is that if `f` is of type `o:A, i:B`, then `mem-rel! A f Bs` is a bit more readable than `mem! B {{map As {{swap f}} }}`. for example, ``` pred f i:term i:prop. f C (decl C _ _). f C (def C _ _ _). mem-rel! C f Ctx. ``` Not sure what the name should be.
1 parent 349dfa1 commit cca32af

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/builtin_stdlib.elpi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ mem [_|L] X :- mem L X.
201201

202202
func exists! list A, (pred A).
203203
exists! [X| _] P :- P X, !.
204-
exists! [_|XS] P :- exists! XS P.
204+
exists! [_|XS] P :- exists! XS P.
205+
206+
func mem-rel! A, (pred A B), list B.
207+
mem-rel! A R L :- exists! L (B\ R A B).
205208

206209
pred exists list A, (pred A).
207210
exists [X|_] P :- P X.
@@ -318,4 +321,4 @@ max _ M M.
318321
func findall prop -> list prop.
319322
findall P L :- findall_solutions P L.
320323

321-
}
324+
}

0 commit comments

Comments
 (0)