8.16.0.1
Fancy App: Scala-Style Magic Lambdas
This package provides a simple shorthand for defining anonymous functions. When required, writing (+ _ 1) becomes equivalent to writing (λ (v) (+ v 1)).
syntax
(#%app expr ...)
Equivalent to normal function application as in racket/base
unless any expr is a _. In that case, the expression
is transformed into an anonymous function expression with one argument for each
_ found among the given exprs. Uses of _ are
converted to positional arguments from left to right.
Examples:
> (map (+ 1 _) (list 1 2 3)) '(2 3 4)
> (map (- _ 1) (list 1 2 3)) '(0 1 2)
> (map (- _ _) (list 10 20 30) (list 1 2 3)) '(9 18 27)
Note that a use of _ that is nested within one of the given exprs does not count. Additionally, using _ after a keyword is not treated specially and does not trigger creation of a keyword argument. Rest arguments are not supported.
Examples: