more
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#lang racket
|
||||
|
||||
|
||||
|
||||
(define-syntax let*
|
||||
(syntax-rules () ;; special tokens
|
||||
[(let* () body ...)
|
||||
(let () body ...)]
|
||||
[(let* ((x v) (xs vs) ...) body ...)
|
||||
(let ((x v)) (let* ((xs vs) ...) body ...))]))
|
||||
|
||||
|
||||
|
||||
(let* [(x 5)
|
||||
(y (+ x 2))]
|
||||
y)
|
||||
;; ->
|
||||
(let ((x 5))
|
||||
(let* ((y (+ x 2)))
|
||||
y))
|
||||
;; ->
|
||||
(let ((x 5))
|
||||
(let ((y (+ x 2)))
|
||||
(let* ()
|
||||
y)))
|
||||
;; ->
|
||||
(let ((x 5))
|
||||
(let ((y (+ x 2)))
|
||||
(let ()
|
||||
y)))
|
||||
|
||||
(define-syntax annd
|
||||
(syntax-rules ()
|
||||
[(annd) #t]
|
||||
[(annd x) (if x x #f)]
|
||||
[(annd x y ...) (if x (annd y ...) #f)]))
|
||||
|
||||
(annd #f (/ 5 0))
|
||||
(and 5 2 3)
|
||||
(annd 5 2 3)
|
||||
Reference in New Issue
Block a user