Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/examples/liars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function distinct(items) {
return is_null(items)
? true
: is_null(tail(items))
? true
: is_null(member(head(items), tail(items)))
? distinct(tail(items))
: false;
}

const betty = amb(1, 2, 3, 4, 5);
const ethel = amb(1, 2, 3, 4, 5);
const joan = amb(1, 2, 3, 4, 5);
const kitty = amb(1, 2, 3, 4, 5);
const mary = amb(1, 2, 3, 4, 5);

require(amb(kitty === 2, betty === 3));
require(amb(ethel === 1, joan === 2));
require(amb(joan === 3, ethel === 5));
require(amb(kitty === 2, mary === 4));
require(amb(mary === 4, betty === 1));

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

list(list('betty', betty), list('ethel', ethel), list('joan', joan),
list('kitty', kitty), list('mary', mary));