Tips for golfing in Racket / Scheme
In Racket, λ
and lambda
are synonymous keywords for constructing anonymous functions, but λ
is 2 bytes where lambda
is 6.
In Scheme, there's no such keyword λ
and you're stuck with lambda
.
Use ~a
to convert numbers and symbols to strings.
When using Racket, bind variables using λ
to shave off a few bytes. In Scheme, lambda
makes this trick not applicable, unless one is binding four or more variables.
Example: One variable saves 2 bytes over let
/define
(define n 55)(* n n) ; 20 bytes
(let([n 55])(* n n)) ; 20 bytes
((λ(n)(* n n))55) ; 18 bytes