From 0c832f9d09801e04b5d9412688f6b6839f25b238 Mon Sep 17 00:00:00 2001 From: Jacob Signorovitch Date: Tue, 13 Jan 2026 20:34:07 -0500 Subject: [PATCH] Fixed TidBIT. --- 09-tidbit/main.rkt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/09-tidbit/main.rkt b/09-tidbit/main.rkt index 67d38bd..5597733 100644 --- a/09-tidbit/main.rkt +++ b/09-tidbit/main.rkt @@ -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}")