Made vapply and lapply primitives for efficiency/partial eval reasons. It means they can exist in emitted code without calling out to eval, which is good. to_compile.kp now both compiles and runs! Now to add more
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
(let1 lambda (vau se (p b1) (wrap (eval (array vau p b1) se)))
|
||||
(let1 current-env (vau de () de)
|
||||
(let1 cons (lambda (h t) (concat (array h) t))
|
||||
(let1 lapply (lambda (f1 p) (eval (cons (unwrap f1) p) (current-env)))
|
||||
(let1 vapply (lambda (f2 p ede) (eval (cons f2 p) ede))
|
||||
(let1 Y (lambda (f3)
|
||||
((lambda (x1) (x1 x1))
|
||||
(lambda (x2) (f3 (lambda (& y) (lapply (x2 x2) y))))))
|
||||
@@ -25,12 +23,12 @@
|
||||
; now maybe errors on can't find helper?
|
||||
(let (helper (rec-lambda recurse (f4 l4 n4 i4)
|
||||
(cond (= i4 (len l4)) n4
|
||||
;(<= i (- (len l) 4)) (recurse f l (concat n (array
|
||||
; (f (idx l (+ i 0)))
|
||||
; (f (idx l (+ i 1)))
|
||||
; (f (idx l (+ i 2)))
|
||||
; (f (idx l (+ i 3)))
|
||||
; )) (+ i 4))
|
||||
(<= i4 (- (len l4) 4)) (recurse f4 l4 (concat n4 (array
|
||||
(f4 (idx l4 (+ i4 0)))
|
||||
(f4 (idx l4 (+ i4 1)))
|
||||
(f4 (idx l4 (+ i4 2)))
|
||||
(f4 (idx l4 (+ i4 3)))
|
||||
)) (+ i4 4))
|
||||
true (recurse f4 l4 (concat n4 (array (f4 (idx l4 i4)))) (+ i4 1)))))
|
||||
(helper f5 l5 (array) 0)))
|
||||
test (map (lambda (x) (+ x 1)) (array 1 2))
|
||||
@@ -42,13 +40,13 @@
|
||||
;old 4
|
||||
;test (+ old 4)
|
||||
;test 4
|
||||
monad (array 'write 1 "test_self_out2" (vau (written code) test))
|
||||
monad (array 'write 1 "test_self_out2" (vau (written code) (map (lambda (x) (+ x 133)) (array written code))))
|
||||
)
|
||||
monad
|
||||
)
|
||||
;(array 'write 1 "test_self_out2" (vau (written code) 7))
|
||||
; end of all lets
|
||||
))))))))
|
||||
))))))
|
||||
; impl of let1
|
||||
; this would be the macro style version (((
|
||||
)) (vau de (s v b) (eval (array (array wrap (array vau (array s) b)) v) de)))
|
||||
|
||||
Reference in New Issue
Block a user