Skip to content

Commit

Permalink
Manually curry tagged-list
Browse files Browse the repository at this point in the history
  • Loading branch information
jaseemabid committed Jul 19, 2018
1 parent dfb18d4 commit ad0788e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/compiler.scm
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,14 @@

;; tagged-list is a helper function for checking syntactic forms.
;;
;; `(tagged-list e tag)` returns true for lists of the form `(tag 1 2 3)`
(define (tagged-list expr name)
(and (list? expr) (eq? name (car expr)) #t))
;; `(tagged-list tag e)` returns true for lists of the form `(tag 1 2 3)`
(define (tagged-list name)
(lambda (expr)
(and (list? expr) (eq? name (car expr)) #t)))

(define (let? expr)
(tagged-list expr 'let))
(define let? (tagged-list 'let))

(define (if? expr)
(tagged-list expr 'if))
(define if? (tagged-list 'if))

(define (letrec? expr)
(and (pair? expr) (eq? 'letrec (car expr))))
Expand All @@ -137,8 +136,7 @@
(and (symbol? x) (lookup x env)))

;; Lambda; arguments at second, body at cddr
(define (lambda? expr)
(tagged-list expr 'lambda ))
(define lambda? (tagged-list 'lambda))

(define (bindings expr)
(assert (let? expr))
Expand Down

0 comments on commit ad0788e

Please sign in to comment.