diff options
| author | mryouse | 2022-07-16 02:41:29 +0000 |
|---|---|---|
| committer | mryouse | 2022-07-16 02:41:29 +0000 |
| commit | 5ece218b4e1461a8ce9c1770aba0e47c829e8362 (patch) | |
| tree | e98bdbe4754cc24f891e114e8201d3a8b724009f /neb | |
| parent | 51c9b6c3773d713f9771f60cac4e84429dbfc181 (diff) | |
implement 'ord', and start integrating string sorting
Diffstat (limited to 'neb')
| -rw-r--r-- | neb/std/strings.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/neb/std/strings.py b/neb/std/strings.py index 4a7166e..00d1fc3 100644 --- a/neb/std/strings.py +++ b/neb/std/strings.py @@ -57,3 +57,10 @@ def interpretRaw(symbol, args, env, ns): return String(str(args[0])) STRINGS.register("raw", Builtin("raw", interpretRaw, [Arg("string", TypeEnum.STRING)], return_type=Type(":string"))) + +def interpretOrd(symbol, args, env, ns): + if len(args[0].value) != 1: + raise InterpretPanic(symbol, "requires a :string of length 1", args[0]) + return Int(ord(args[0].value)) + +STRINGS.register("ord", Builtin("ord", interpretOrd, [Arg("char", TypeEnum.STRING)], return_type=Type(":int"))) |
