Created
April 15, 2018 05:35
-
-
Save Jake-Gillberg/61dbfabbe262f9d86a70d2159a735e9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import LinkedList in { | |
contract makeGameBoard(return) { | |
new players in { | |
players!([]) | | |
contract registerPlayer(endorse) { | |
new friends, getFriends in { | |
friends!([]) | | |
contract endorse(@subject, @level, return) { | |
for (oldFriends <- friends) { | |
LinkedList!("prepend", [[subject, level], *oldFriends], *friends) | |
} | |
} | | |
contract getFriends(@level, return) { | |
new filter in { | |
contract filter(@friend, @acc, return) = { | |
match friend { | |
[s, l] => { | |
match l == level { | |
true => { | |
LinkedList!("prepend", [s, acc], return) | |
} | |
_ => { return!(acc) } | |
} | |
} | |
_ => { return!(acc) } | |
} | |
} | | |
for (f <- friends) { | |
LinkedList!("fold", [*f, [], *filter], return) | | |
friends!(f) | |
} | |
} | |
} | | |
for (oldPlayers <- players) { | |
LinkedList!("prepend", [*getFriends, *oldPlayers], *players) | |
} | |
} | |
} | | |
contract getPlayers(return) { | |
new gather in { | |
contract gather(@player, @acc, return = { | |
LinkedList!("prepend", [player, acc], return) | |
} | | |
for (p <- players) { | |
LinkedList!("fold", [*p, [], *gather], return) | |
players!(p) | |
} | |
} | |
} | |
contract getCerts(seed, level, return) { | |
// ouch. | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment