master
cynic 3 years ago
parent 4944adce71
commit 6b8f64648a
  1. 1
      .gitignore
  2. 16
      lib.py
  3. 9
      test.klambda

1
.gitignore vendored

@ -0,0 +1 @@
__pycache__

@ -25,6 +25,20 @@ def execute(ctx):
return subs
else:
return to if i == fr else i
def _truthy(i):
if i[0] == "string":
return True if i[1] else False
elif i[0] == "number":
return False if i[1] == 0 else True
elif type(i) == type([]):
good = False
for j in i:
if _truthy(j):
good = True
break
return good
else:
return False
if type(ctx) == type([]) and ctx[0][0] == "identifier":
subs = list(
map(lambda a: _execute(a), ctx)
@ -42,6 +56,8 @@ def execute(ctx):
elif ctx[0] == _ident("defun"):
funcspace[subs[1]] = subs[2]
return funcspace[subs[1]]
elif ctx[0] == _ident("cond"):
return _execute(subs[2]) if _truthy(_execute(subs[1])) else _execute(subs[3])
elif ctx[0] in funcspace:
prototype = funcspace[ctx[0]]
for idx, arg in enumerate(subs[1:]):

@ -3,6 +3,11 @@
"builtins" "print" (id $1)
)
)
(defun input
(id miracle
"builtins" "input" ("")
)
)
(defun thesis
(id spit
("this language belongs to makise kurisu. there are many like it, but this one is hers.")
@ -12,4 +17,8 @@
(spit
("lol swej" (+ 9000 1) a)
)
(cond ("", (+ 0 1))
(id spit ("one"))
(id spit ("zero"))
)
(thesis)
Loading…
Cancel
Save