Skip to content

Instantly share code, notes, and snippets.

@PaulMaynard
Last active February 5, 2020 22:15
Show Gist options
  • Save PaulMaynard/fb0a977fd2260e2b1e66e6562bba0b82 to your computer and use it in GitHub Desktop.
Save PaulMaynard/fb0a977fd2260e2b1e66e6562bba0b82 to your computer and use it in GitHub Desktop.
(require rackunit)
; lambda
(check-true (lambda? '(lambda (x) x)))
(check-true (lambda? '(lambda (x y z) z y x)))
(check-false (lambda? '(lambda (x 1) x)))
(check-false (lambda? '(lambda (x))))
(check-false (lambda? '3))
(check-equal? '(x) (lambda-params '(lambda (x) y)))
(check-equal? '(y) (lambda-body '(lambda (x) y)))
; apply
(check-false (apply? '(lambda (x) x)))
(check-false (apply? '(define x 1)))
(check-false (apply? 'x))
(check-false (apply? '(x)))
(check-true (apply? '(x y)))
(check-true (apply? '(x y z)))
(check-equal? 'x (apply-func '(x y)))
(check-equal? '(y) (apply-args '(x y)))
; define
(check-true (define? '(define x 3)))
(check-true (define-basic? '(define x 3)))
(check-false (define-basic? '(define (x) 3)))
(check-false (define-func? '(define x 3)))
(check-true (define-func? '(define (x) 3)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment