std.lib.function

+specialized+

arg-check

added in 3.0

(arg-check f num)(arg-check f num message)

counts the number of non-varidic argument types

(arg-check (fn x) 1) => true

(arg-check (fn x & xs) 1) => true

(arg-check (fn x & xs) 0) => (throws-info {:required 0 :actual () 1})

arg-count

added in 3.0

(arg-count f)

counts the number of non-varidic argument types

(arg-count (fn x)) => 1

(arg-count (fn x & xs)) => []

(arg-count (fn (x) (x y))) => 1 2

fn-form

added in 3.0

(fn-form cls method bindings body)

creates a lambda form

fn-tags

added in 3.0

(fn-tags bindings)

creates tags for fn

(fn-tags ^{:tag ’long} []) => “Long” nil nil

(fn-tags ^{:tag ’long} [^{:tag ’long} [] ^{:tag ’int} []]) => “Long” “Long” “Int”

fn:call-body

added in 4.1

(fn:call-body doc? attr? more)

creates callable args while preserving multi-arity bodies

(fn:call-body ’x ’(inc x) []) => ’["" {} (x(inc x))]

(fn:call-body ’(x(inc x)) ’(x y(+ x y)) []) => ’["" {} ((x(inc x)) (x y(+ x y)))]

fn:consumer

macro

added in 3.0

(fn:consumer bindings & body)

creates a java unary function

fn:create-args

added in 3.0

(fn:create-args [doc? attr? & more :as arglist])

creates args for the body

(fn:create-args ’[x(inc x) nil nil]) => ’("" {} x(inc x))

fn:def-form

added in 3.0

(fn:def-form name attrs body)(fn:def-form name doc attrs arglist body)

creates a def form

fn:init-args

added in 3.0

(fn:init-args doc? attr? more)

creates init args

(fn:init-args ’x ’(inc x) []) => ’["" {} (x(inc x))]

fn:lambda

macro

added in 3.0

(fn:lambda bindings & body)

creates java unary/binary functions

fn:predicate

macro

added in 3.0

(fn:predicate bindings & body)

creates a java predicate

(-> (fn:predicate ^long a(< a 10)) (.test 3)) => true

fn:supplier

macro

added in 3.0

(fn:supplier bindings & body)

creates a java supplier

varg-count

added in 3.0

(varg-count f)

counts the number of arguments types before variable arguments

(varg-count (fn x y & xs)) => 2

(varg-count (fn x)) => nil

vargs?

added in 3.0

(vargs? f)

checks that function contain variable arguments

(vargs? (fn x)) => false

(vargs? (fn x & xs)) => true