Experimenting with fungll optimization, implement the okmij.org poly-variadic fix-point combinator for mutual recursion

This commit is contained in:
Nathan Braswell
2020-10-17 11:59:54 -04:00
parent 45ecb25bb1
commit d689a59097
8 changed files with 58 additions and 16 deletions

View File

@@ -127,5 +127,21 @@ obj hash_set<T> (Object, Serializable) {
}
}
fun pop(): T {
return data.pop().first
}
fun union(other: hash_set<T>): hash_set<T> {
for_each(fun(i: T) {
other.add(i)
})
return other
}
fun operator-(items: ref hash_set<T>): hash_set<T> {
var to_ret.copy_construct(this): hash_set<T>
items.for_each(fun(i: T) {
to_ret.remove(i)
})
return to_ret
}
}