diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-03-07 02:18:26 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-03-07 02:18:26 +0200 |
| commit | ae5fee63f160643a397d18e9e0658275606bc4d4 (patch) | |
| tree | f68af302374f9ae3c9dbb28dab5547036252d559 /examples/std.ct | |
| download | ek-ae5fee63f160643a397d18e9e0658275606bc4d4.tar.gz ek-ae5fee63f160643a397d18e9e0658275606bc4d4.zip | |
initial commit
Diffstat (limited to 'examples/std.ct')
| -rw-r--r-- | examples/std.ct | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/std.ct b/examples/std.ct new file mode 100644 index 0000000..339459f --- /dev/null +++ b/examples/std.ct @@ -0,0 +1,35 @@ +type std { + init(mut * any); + deinit(mut * any); + copy(mut * any, * any); + move(mut * any, mut * any); +} + +/* these as well could be way optimized for builtin types */ +type comparable { + equal(* any, * any) bool; + less_than(* any, * any) bool; +} + +/* I'm imagining that if someone provides a specific function for these, it will + * be used rather than these ones, but that the minimum to implement comparable + * is as small as possible this should be fine */ +pub not_equal(a * comparable, b * comparable) bool +{ + return !equal(a, b); +} + +pub greater_than(a * comparable. b * comparable) bool +{ + return !equal(a, b) && !less_than(a, b); +} + +pub less_or_equal(a * comparable, b * comparable) bool +{ + return !greater_than(a, b); +} + +pub greater_or_equal(a * comparable, b * comparable) bool +{ + return !less_than(a, b); +} |
