[ create a new paste ] login | about

Link: http://codepad.org/JcuniUhD    [ raw code | output | fork ]

Scheme, pasted on Sep 25:
(define-syntax print 
  (syntax-rules ()
    ((_ body ...) (begin
                    (for-each (lambda (x) (begin (display x)(newline))) (list body ...))))))

(define-syntax aif
    (syntax-rules ()
      ((_ name test true-arm false-arm)
       (let ((name test))
         (if name
             true-arm
             false-arm)))
      ((_ name pred test true-arm false-arm)
       (let ((name test))
         (if (pred name)
             true-arm
             false-arm)))))

(define x 'd)

(print (member x '(a b c)))

(print (let ((tail (member x '(a b c))))
  (if tail
     tail
     'not-found)))

(print (aif tail (member x '(a b c))
    tail
    'not-found))


Output:
1
2
3
#f
not-found
not-found


Create a new paste based on this one


Comments: