[ create a new paste ] login | about

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

Scheme, pasted on Jun 16:
(module m mzscheme
  (define-syntax args
    (syntax-rules (quasiquote unquote-splicing)
      [(_ (x ...) (`,@y z ...))
       (args (x ... ,@y) (z ...))]
      [(_ (x ...) (y z ...))
       (args (x ... ,y) (z ...))]
      [(_ (x ...) ())
       `(x ...)]))

  (define-syntax app
    (syntax-rules ()
      [(_ f x ...) (apply f (args () (x ...)))]))

  (provide (rename app #%app)))


(require m)

(define a '(1 2 3))

(write (list 0 `,@a))
(newline)

(write (+ 1 `,@(map add1 a) 5))
(newline)


Output:
1
2
(0 1 2 3)
15


Create a new paste based on this one


Comments: