Fixed TidBIT.

This commit is contained in:
2026-01-13 20:34:07 -05:00
parent 4893be34fb
commit 0c832f9d09
+6 -4
View File
@@ -49,11 +49,11 @@ The grammar:
(define (binding-encountered bd id)
(lambda ([s : Symbol]) (if (symbol=? s id) 1 (add1 (bd s)))))
(: currycall : TIDBIT (Listof TIDBIT) BINDING-DEPTH -> CORE)
(: currycall : CORE (Listof TIDBIT) BINDING-DEPTH -> CORE)
(define (currycall body args bd)
(match args
['() (preprocess body bd)]
[else (CCall (currycall body (rest args) bd) (preprocess (first args) bd))]))
['() body]
[(cons f r) (currycall (CCall body (preprocess f bd)) r bd)]))
(: curryfn : (Listof Symbol) TIDBIT BINDING-DEPTH -> CORE)
(define (curryfn params body bd)
@@ -74,7 +74,7 @@ The grammar:
[(With name value body) (CCall (CFun (preprocess body (binding-encountered bd name)))
(preprocess value bd))]
[(Fun params body) (curryfn params body bd)]
[(Call body args) (currycall body args bd)]))
[(Call body args) (currycall (preprocess body bd) args bd)]))
(: parse-sexpr : Sexpr -> TIDBIT)
; Parses Sexprs into TIDBITs.
@@ -156,6 +156,8 @@ The grammar:
[else (error 'run "evaluation returned a non-number: ~s"
result)])))
(test (run "{call {fun {x y z} {+ x {* y z}}} 1 2 3}") => 7)
(test (run "{{fun {x y z} {+ x {+ y z}}} of 1 2 3}") => 6)
(test (run "{{fun {x} {+ x 1}} of 4}")