Skip to content

Commit 9ea98be

Browse files
committed
Fix example correctness
1 parent ff89caf commit 9ea98be

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/examples/liars.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +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+
}
110

211
const betty = amb(1, 2, 3, 4, 5);
312
const ethel = amb(1, 2, 3, 4, 5);
413
const joan = amb(1, 2, 3, 4, 5);
514
const kitty = amb(1, 2, 3, 4, 5);
615
const mary = amb(1, 2, 3, 4, 5);
716

8-
require((kitty === 2) || (betty === 3));
9-
require((ethel === 1) || (joan === 2));
10-
require((joan === 3) || (ethel === 5));
11-
require((kitty === 2) || (mary === 4));
12-
require((mary === 4) || (betty === 1));
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));
1322

1423
require(distinct(list(betty, ethel, joan, kitty, mary)));
1524

1625
list(list('betty', betty), list('ethel', ethel), list('joan', joan),
17-
list('kitty', kitty), list('mary', mary));
26+
list('kitty', kitty), list('mary', mary));

0 commit comments

Comments
 (0)