-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtc.tel
More file actions
21 lines (18 loc) · 1.09 KB
/
tc.tel
File metadata and controls
21 lines (18 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- returns whether the ascii value of a character is even
isEven = \n -> { \i -> left i -- test for if a recursive call should be made, or the base case should be called
, \recur i -> recur (left (left i), not (right i)) -- function that will be made recursive, where recur is the continuation
, \i -> right i -- base case call
} (n, 1)
-- limit the input space. This is necessary, because it's impossible to find limits to recursive functions operating on unbounded data
validAscii = \x -> assert (not ($127 left x)) "!"
main = \input -> let userInput = left input
firstChar = left userInput
limInput : validAscii = firstChar
oldState = right input
output = concat ["R "
, if isEven limInput then "EV" else "O" -- breaks
-- , if isEven limInput then "E" else "O" -- works
]
in if not input
then (" ", 1)
else (output, 0)