JanetDocsPlaygroundI'm feeling luckyGitHub sign in

short-fn



    macro
    boot.janet on line 1987, column 1

    (short-fn arg)

    Shorthand for fn. Arguments are given as $n, where n is the 
    0-indexed argument of the function. $ is also an alias for the 
    first (index 0) argument. The $& symbol will make the anonymous 
    function variadic if it apears in the body of the function - it can 
    be combined with positional arguments.

    Example usage:

    * (short-fn (+ $ $)) - A function that doubles its arguments.
    * (short-fn (string $0 $1)) - accepting multiple args
    * |(+ $ $) - use pipe reader macro for terse function literals
    * |(+ $&) - variadic functions


1 exampleSign in to add an example
Loading...
(map  (fn [x] (< x 10))    [8 9 10 11])  # => @[true true false false]
(map  (short-fn (< $ 10))  [8 9 10 11])  # => @[true true false false]
(map  |(< $ 10)            [8 9 10 11])  # => @[true true false false]
cellularmitosisPlayground