Last active
December 2, 2025 20:02
-
-
Save DeedleFake/fbc6d65d6dd7d17c314e0f636b2017ff to your computer and use it in GitHub Desktop.
String set implemented in Par.
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
| type Set<a> = iterative box choice { | |
| .add(a) => self, | |
| .has(a) => (Bool) self, | |
| .remove(a) => self, | |
| } | |
| dec Set.String : [List<String>] Set<String> | |
| def Set.String = [list] do { | |
| let list: List<(String) !> = list.begin.case { | |
| .end! => .end!, | |
| .item(str) list => .item((str) !) list.loop, | |
| } | |
| let map = BoxMap.String(type !)(list) | |
| } in begin box case { | |
| .add(a) => do { map.put(a, !) } in loop, | |
| .has(a) => map.get(a).case { | |
| .ok! => (.true!) loop, | |
| .err! => (.false!) loop, | |
| }, | |
| .remove(a) => do { map.delete(a) } in loop, | |
| } |
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
| // Usage is a bit odd. | |
| def Main: ! = chan yield { | |
| let set = Set.String(*()) | |
| set.add("test") | |
| set.has("test")[test] | |
| test.case { | |
| .true! => { Debug.Log("test") }, | |
| .false! => {}, | |
| } | |
| yield! | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment