Compare commits

...

4 Commits

  1. 14
      lib.py
  2. 1
      lib/aids.klambda
  3. 21
      lib/loop.klambda
  4. 3
      lib/string.klambda
  5. 6
      test.klambda

@ -2,8 +2,6 @@
# BET UR MAD BAKADESU HAHAHAHHAHAHAHAH
# t. cirno
def execute(program):
import traceback, copy
def _execute(ctx, ids):
@ -58,13 +56,14 @@ def execute(program):
return ("lambda", (ctx[1], ctx[2]))
elif ctx[0] == _ident("cond"):
return _execute(ctx[2], lids) if _truthy(_execute(ctx[1], lids)) else _execute(ctx[3], lids)
elif ctx[0][1] == "id":
return ctx[1] if len(ctx[1:]) == 1 else ctx[1:]
subs = _fixarr(list(map(lambda a: _execute(a, lids), ctx)))
if ctx[0][1][0] == "$":
return subs
elif ctx[0][1] == "id":
return subs[1] if len(subs[1:]) == 1 else subs[1:]
elif ctx[0] == _ident("miracle"):
return _box(eval(_destr(subs[1]))[_destr(subs[2])](*[(i if type(i) == type([]) else i[1]) for i in _fixarr(subs[3])]))
elif ctx[0] == _ident("def"):
@ -107,11 +106,12 @@ def execute(program):
return _execute(subs, lids)
elif ctx[0][0] == "lambda":
prototype = ctx[0][1][1]
ephemeral_space = copy.copy(ids)
for idx, arg in enumerate(ctx[0][1][0]):
prototype = _recursereplace(prototype, arg, ctx[1:][idx])
return _execute(prototype, lids)
ephemeral_space[arg] = ctx[1:][idx]
#prototype = _recursereplace(prototype, arg, ctx[1:][idx])
return _execute(prototype, ephemeral_space)
else:
#print("base", ctx)
if type(ctx) == type([]):
return list(
map(lambda a: _execute(a, lids), ctx)

@ -5,3 +5,4 @@ INCLUDE:./loop.klambda
INCLUDE:./lists.klambda
INCLUDE:./kokoro.klambda
INCLUDE:./booleans.klambda
INCLUDE:./string.klambda

@ -1,8 +1,13 @@
DEFINE:loop:(def loop (lambda (counter max)\
(all\
statement\
(cond (= counter max)\
counter\
(loop (+ counter 1) max)))))\
(loop start end)\
:start:end:statement
(def loop (lambda (max i statement)
(all
statement
(cond (= i max)
false
(loop max (- i 1) (id statement))))))
(def each
(lambda (it action)
(loop 0 (- (length it) 1)
(id all
(def item (at i it))
action))))

@ -0,0 +1,3 @@
(def str2lst (lambda (l)
(miracle
"__builtins__" "list" (l))))

@ -15,9 +15,11 @@ INCLUDE:./lib/aids.klambda
"adult (hag)"
"not adult (uoh)"))
loop:0:100:(spit (cond (% counter 15) (cond (% counter 5) (cond (% counter 3) counter "fizz") "buzz") "fizzbuzz"))
(loop 0 100
(id spit (cond (% i 15) (cond (% i 5) (cond (% i 3) i "fizz") "buzz") "fizzbuzz")))
(def moeblob ("moe" "moe~" "kyun!!"))
loop:0:(- (length moeblob) 1):(spit (at counter moeblob))
(loop 0 (- (length moeblob) 1)
(id spit (at i moeblob)))
(thesis)
Loading…
Cancel
Save