Skip to content

Commit 73daa07

Browse files
committed
Merge remote-tracking branch 'origin/add-examples' into non-det-examples
2 parents b7781c8 + 9ea98be commit 73daa07

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/examples/liars.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function distinct(items) {
2+
return is_null(items)
3+
? true
4+
: is_null(tail(items))
5+
? true
6+
: is_null(member(head(items), tail(items)))
7+
? distinct(tail(items))
8+
: false;
9+
}
10+
11+
const betty = amb(1, 2, 3, 4, 5);
12+
const ethel = amb(1, 2, 3, 4, 5);
13+
const joan = amb(1, 2, 3, 4, 5);
14+
const kitty = amb(1, 2, 3, 4, 5);
15+
const mary = amb(1, 2, 3, 4, 5);
16+
17+
require(amb(kitty === 2, betty === 3));
18+
require(amb(ethel === 1, joan === 2));
19+
require(amb(joan === 3, ethel === 5));
20+
require(amb(kitty === 2, mary === 4));
21+
require(amb(mary === 4, betty === 1));
22+
23+
require(distinct(list(betty, ethel, joan, kitty, mary)));
24+
25+
list(list('betty', betty), list('ethel', ethel), list('joan', joan),
26+
list('kitty', kitty), list('mary', mary));

0 commit comments

Comments
 (0)