Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Macro to use "λ" character as "lambda" in R5RS Scheme?

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.

like image 512
GlassGhost Avatar asked Nov 27 '25 04:11

GlassGhost


1 Answers

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)
like image 148
uselpa Avatar answered Dec 01 '25 06:12

uselpa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!