Skip to content

Instantly share code, notes, and snippets.

@Jake-Gillberg
Created April 15, 2018 05:35
Show Gist options
  • Save Jake-Gillberg/61dbfabbe262f9d86a70d2159a735e9a to your computer and use it in GitHub Desktop.
Save Jake-Gillberg/61dbfabbe262f9d86a70d2159a735e9a to your computer and use it in GitHub Desktop.
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