erp12.fijit.function

Utilities for constructing instances of scala’s Function* traits.

This namespace defines a suite or types (via deftype) that each correspond to a Scala function with a different arity. They all are constructed with a single argument value: a clojure function with the same arity.

Each type also implements Serializable and clojure.lang.IFn so that instances can be called as normal Clojure functions.

->fn0

(->fn0 f)

Wraps a Clojure function with arity 0 in a Scala Function0.

->fn1

(->fn1 f)

Wraps a Clojure function with arity 1 in a Scala Function1.

->fn2

(->fn2 f)

Wraps a Clojure function with arity 2 in a Scala Function2.

->fn3

(->fn3 f)

Wraps a Clojure function with arity 3 in a Scala Function3.

->fn4

(->fn4 f)

Wraps a Clojure function with arity 4 in a Scala Function4.

->fn5

(->fn5 f)

Wraps a Clojure function with arity 5 in a Scala Function5.

scala-fn

macro

(scala-fn params & body)

Creates a Scala function using idiomatic Clojure syntax.

Scala utilizes a different function type (expressed as a trait) depending on the number of arguments, and thus the type of the returned value will different depending on the arity of the function being defined.