We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d33c16f commit 392abafCopy full SHA for 392abaf
src/runtime/lfortran_builtin.py
@@ -0,0 +1,28 @@
1
+from ltypes import i32
2
+from sys import exit
3
+
4
5
+def ord(s: str) -> i32:
6
+ """
7
+ Returns an integer representing the Unicode code
8
+ point of a given unicode character. This is the inverse of `chr()`.
9
10
+ if s == '0':
11
+ return 48
12
+ elif s == '1':
13
+ return 49
14
+ else:
15
+ exit(1)
16
17
18
+def chr(i: i32) -> str:
19
20
+ Returns the string representing a unicode character from
21
+ the given Unicode code point. This is the inverse of `ord()`.
22
23
+ if i == 48:
24
+ return '0'
25
+ elif i == 49:
26
+ return '1'
27
28
0 commit comments