Skip to main content

Anatomy of a Function

The following are all the predicates that you can specify when creating a function.

namestringFunction name
params(multi) stringList of parameters this function supports.
codestringActual ledger code
docstringA docstring for this function.
languagestringProgramming language used (not yet implemented, currently only Clojure supported)
specJSON(not yet implemented) Optional spec for parameters. Spec should be structured as a map, parameter names are keys and the respective spec is the value.

In the next lesson, we'll be talking a lot more about _fn/code, but for now take a look at an example function, which subtracts 3 from a value:

"_id": "_fn",
"name": "minus3",
"params": ["a"],
"code": "(- a 3)",
"doc": "Subtracts 3 from a value, a"

As you can see above, our code takes a parameter, a. We declare a in _fn/params, and we can therefore use it in our code.