Axon Function Ext. Core Flashcards
abs
Return absolute value of a number, if null return null
abs(val)
add
Add item to the end of a list and return a new list.
add(val, item)
addAll
Add all the items to the end of a list and return a new list.
addAll (val, items)
addCol
Add a column to a grid by mapping each row to a new call value. The col parameter may be a simple string name or may be a distionary which must have a “name” tag (any other tags become column meta-data). The mapping funtion takes (row) and returns the new cell values for the column.
addCol (grid, col, fn)
addColMeta
Return a new grid with additional column meta-data
addColMeta (grid, name, meta)
addMeta
Add grid level meta-data tags.
addMeta(grid, meta)
addRow
Add an additional Dict row to the end of a grid.
addRow (grid, newRow)
addRows
Add an list of rows to the end of a grid. The newRows may be expressed as list of Dict or a Grid.
addRows (grid, newRows)
all
Return if all the items in a list, dict, or grid match the given test function. If the collection is empty, then return true.
If working with a list, the function takes (val) or (val, index) and returns true or false.
If working with a dict, theu function takes (val) or (val, name) and returns true or false.
If working with a grid, the function take (row) or (row, index) and returns true or false.
[1, 3, 5] . all v => v.isOdd >> true
[1, 3, 6] .all(isOdd) >>false
any
any(val, fn)
Return if any the items in a list, dict, or grid match the given test function. If the collection is empty, then return false.
If working with a list, the function takes (val)
or (val, index)
and returns true or false.
If working with a dict, the function takes (val)
or (val, name)
and returns true or false.
If working with a grid, the function takes (row)
or (row, index)
and returns true or false.
Examples:
[1, 3, 5].any v =\> v.isOdd \>\> true [2, 4, 6].any(isOdd) \>\> false
as
as(val, unit)
Set the unit of a number. Unlike to no conversion of the scalar of the number is performed. The target unit can be a unit string or a number in which case the scalar value of the unit parameter is ignored (by convention should be 1).
avg
avg(val, acc)
Fold multiple values into their standard average or arithmetic mean. This function is the same as math::mean
. Null values are ignored. Return null if no values.
capitalize
capitalize(val)
Return this string with the first character converted to uppercase. The case conversion is for ASCII only.
chart
chart(val)
Set the grid visualization view to chart.
checkSyntax
checkSyntax(src)
Given an axon expression, validate the syntax. If there are no errors then return an empty grid. If there are errors then return a grid with the “err” tag and a “line” and “dis” column for each error found.
col
col(grid, name, checked: true)
Get a column by its name. If not resolved then return null or throw UnknownNameErr based on checked flag.
colNames
colNames(grid)
Get the column names a list of strings.
colToList
colToList(grid, col)
Get a column as a list of the cell values ordered by row.
cols
cols(grid)
Get the columns from a grid as a list.
colsToLocale
colsToLocale(grid)
Map each col display string to its localized tag name if the col does not already have a display string. Also see Grid.colsToLocale and Localization.
commit
commit(diffs)
Commit a diff
or list of diffs to the folio database.
If one diff is passed, return the new record. If a list of diffs is passed return a list of new records.
Examples:
// add new record newRec: commit(diff(null, {dis:"New Rec!"}, {add})) // add someTag to some group of records readAll(filter).toRecList.map(r =\> diff(r, {someTag})).commit
Side effects:
- writes to folio database
- clears context read cache
concat
concat(list, sep: "")
Concatenate a list of items into a string.
Examples:
[1, 2, 3].concat \>\> "123" [1, 2, 3].concat(",") \>\> "1,2,3"
contains
contains(val, x)
Return if val
contains x
:
- if
val
is Str, thenx
is substring. - if
val
is List, thenx
is item to search. - if
val
is Range, then isx
inside the range inclusively - if
val
is DateSpan, then isx
a date in the span
context
context()
Get the current context as a Dict with the following tags:
-
username
for current user -
userRef
if user maps to a rec in current project -
projName
if evaluating in context of a project -
ruleRef
if evaluating in context of a spark engine rule -
locale
current locale