mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
Initial file
This commit is contained in:
parent
ffccd7ae0b
commit
bc732d3cb9
3 changed files with 54 additions and 0 deletions
35
srfi/2.scm
Normal file
35
srfi/2.scm
Normal 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
8
srfi/2.sld
Normal 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
11
srfi/test-2.scm
Normal 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))
|
||||
))
|
Loading…
Add table
Reference in a new issue