Initial file

This commit is contained in:
Justin Ethier 2016-08-20 03:16:10 -04:00
parent ffccd7ae0b
commit bc732d3cb9
3 changed files with 54 additions and 0 deletions

35
srfi/2.scm Normal file
View file

@ -0,0 +1,35 @@
;;;
;;; husk-scheme
;;; http://justinethier.github.com/husk-scheme
;;;
;;; Implementation of SRFI-2: and-let*
;;;
(define-syntax and-let*
(syntax-rules ()
; Special case
((and-let* ())
#t)
; No CLAWS, just body
((and-let* () body ...)
(begin body ...))
; Special cases of below - CLAWS with no body
((and-let* ((var expr)) )
(let ((var expr))
(and var)))
((and-let* ((expr)))
(let ((tmp expr))
(and tmp )))
((and-let* (expr))
(let ((tmp expr))
(and tmp )))
; General case - CLAWS and body
((and-let* ((var expr) . rest) . body)
(let ((var expr))
(and var (and-let* rest . body))))
((and-let* ((expr) . rest) . body)
(let ((tmp expr))
(and tmp (and-let* rest . body))))
((and-let* (expr . rest) . body)
(let ((tmp expr))
(and tmp (and-let* rest . body))))))

8
srfi/2.sld Normal file
View file

@ -0,0 +1,8 @@
(define-library (2) ; (srfi 2)
(import (scheme base))
(export
and-let*
)
(include "2.scm")
(begin)
)

11
srfi/test-2.scm Normal file
View file

@ -0,0 +1,11 @@
(import (scheme base)
(scheme write)
(scheme cyclone pretty-print)
(2))
(pretty-print `(
,(and-let* ((x 1) (y 2))
(+ x y))
,(and-let* ((x 1) (y 2) (#f))
(+ x y))
))