3

Is there a Macro to use "λ" character as "lambda" in R5RS Scheme? From here In Gambit "scheme-r5rs" I tried:

(define-syntax λ
  (syntax-rules ()
    ((_ . more) (lambda . more))))

But I keep getting Ill-formed expression error.

GlassGhost
  • 16,906
  • 5
  • 32
  • 45

1 Answers1

2

You seem to be looking for a reader macro, but I don't think they are standardised in Scheme.

This works:

# pu@pumbair: ~  cat test2.scm
(define-syntax λ
    (syntax-rules ()
       ((_ param body ...) (lambda param body ...))))
(display ((λ (x y) (+ x y)) 1 2)) (newline)
(display ((λ () 1))) (newline)
(display ((λ (a . b) b) 'a 'b 'c)) (newline)

# pu@pumbair: ~  gsi -:s test2.scm
3
1
(b c)
uselpa
  • 18,732
  • 2
  • 34
  • 52