外观
lib-axon 库参考
原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793619766/FIN+5.3.1+lib-axon 中文整理基于 FIN 5.3.1
导读: 本页为
lib-axon的 API / 标签 / 函数参考文档。
以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。
目录(导读)
- lib
- meta
- tags
- funcs
- def
- supertypes
- subtypes
- tags
- abs(val)
- add(val, item)
- addAll(val, items)
- addCol(grid, col, fn)
- addColMeta(grid, name, meta)
- addCols(a, b)
- addMeta(grid, meta)
- addRow(grid, newRow)
- addRows(grid, newRows)
- all(val, fn)
- any(val, fn)
- as(val, unit)
- avg(val, acc)
- call(func, args: null)
- capitalize(val)
- clamp(val, min, max)
- col(grid, name, checked: true)
- colNames(grid)
- colToList(grid, col)
- collect(stream, to: null)
- cols(grid)
- colsToLocale(grid)
- compDef(name, checked: true)
- concat(list, sep: "")
- conjuncts()
- contains(val, x)
- coord(lat, lng)
- coordDist(c1, c2)
- coordLat(coord)
- coordLng(coord)
- count(val, acc)
- curFunc()
- date(val, month: null, day: null)
- dateTime(d, t, tz: null)
- day(d)
- dayOfYear(val)
- debugType(val)
- decapitalize(val)
- def(symbol, checked: true)
- defs()
- dis(dict, name: null, def: "")
- dst(dt)
- each(val, fn)
- eachDay(dates, fn)
- eachMonth(dates, fn)
- eachWhile(val, fn)
- echo(x)
- end(val)
- endsWith(val, sub)
- equals(a, b)
- eval(expr)
- evalToFunc(expr)
- filter(val, filterExpr)
- filterToFunc(filterExpr)
- find(val, fn)
- findAll(val, fn)
- first(val)
- firstOfMonth(date)
- flatMap(val, fn)
- flatten(list)
- fold(val, fn)
- foldCol(grid, colName, fn)
- foldCols(grid, colSelector, newColName, fn)
- foldEnd()
- foldStart()
- format(val, pattern: null)
- fromJavaMillis(millis, tz: null)
- func(name, checked: true)
- funcs(filterExpr: null)
- get(val, key)
- getSafe(val, key)
- gridColKinds(grid)
- gridColsToDict(grid, colToKey, colToVal)
- gridReplace(grid, from, to)
- gridRowsToDict(grid, rowToKey, rowToVal)
- has(val, name)
- hour(t)
- hoursInDay(dt)
- index(val, x, offset: 0)
- indexr(val, x, offset: Number.negOne)
- insert(val, index, item)
- insertAll(val, index, items)
- isAlpha(num)
- isAlphaNum(num)
- isBool(val)
- isDate(val)
- isDateTime(val)
- isDict(val)
- isDigit(num, radix: 10)
- isDuration(val)
- isEmpty(val)
- isEven(val)
- isFunc(val)
- isGrid(val)
- isHisGrid(val)
- isKeyword(val)
- isLeapYear(year)
- isList(val)
- isLower(num)
- isMetric(val: null)
- isNaN(val)
- isNonNull(val)
- isNull(val)
- isNumber(val)
- isOdd(val)
- isRef(val)
- isSpace(num)
- isSpan(val)
- isStr(val)
- isTagName(n)
- isTime(val)
- isUpper(num)
- …(其余标题见英文正文)
概述(中译)
Axon 核心库
API 正文(英文)
tags
| admin | Requires admin permission |
| disableOverridableChecks | Disables function overridable checking |
| err | Indicates an error condition, dis should contain display message |
| errTrace | Exception stack trace |
| expr | Axon expression string |
| foldOn | Registers a function as folding a given value type |
| func | Axon function |
| name | Name key |
| overridable | Applied to an ext function to enable override by project record functions |
| src | Source code |
| su | Requires superuser permission |
funcs
| abs | Return absolute value of a number, if null return null |
| add | Add item to the end of a list and return a new list |
| addAll | Add all the items to the end of a list and return a new list |
| addCol | Add a column to a grid by mapping each row to a new cell value |
| addColMeta | Return a new grid with additional column meta-data |
| addCols | Add grid b as a new set of columns to grid a |
| addMeta | Return new grid with additional grid level meta-data tags |
| addRow | Add an additional Dict row to the end of a grid |
| addRows | Add an list of rows to the end of a grid |
| all | Return if all the items in a list, dict, or grid match the given test function |
| any | Return if any the items in a list, dict, or grid match the given test function |
| as | Set the unit of a number |
| avg | Fold multiple values into their standard average or arithmetic mean |
| call | Reflectively call a function with the given arguments |
| capitalize | Return this string with the first character converted to uppercase |
| clamp | Clamp the number val between the min and max |
| col | Get a column by its name |
| colNames | Get the column names a list of strings |
| colToList | Get a column as a list of the cell values ordered by row |
| collect | Collect stream into a in-memory list or grid |
| cols | Get the columns from a grid as a list |
| colsToLocale | Localize column display names |
| compDef | Return component definition |
| concat | Concatenate a list of items into a string |
| conjuncts | List conjunct definitions in the context namespace as Def[] |
| contains | Return if val contains x |
| coord | Construct a Coord from two Numbers in decimal degrees |
| coordDist | Compute the great-circle distance between two Coords |
| coordLat | Latitude of a Coord as a Number |
| coordLng | Longitude of a Coord as a Number |
| count | Fold multiple values into their total count Return zero if no values |
| curFunc | Get the current top-level function's tags |
| date | If val is a DateTime |
| dateTime | Construct a DateTime from a date, time, and timezone name |
| day | Get day of month as integer between 1 to 31 from date or datetime |
| dayOfYear | Given a DateTime or Date, return the day of the year |
| debugType | Return a string of the given value's type |
| decapitalize | Return this string with the first character converted to lowercase |
| def | Lookup a def by its symbol name (Str or Symbol) |
| defs | List all definitions in the context namespace as Def[] |
| dis | Get display string for dict or the given tag |
| dst | Return if a DateTime is in daylight saving time |
| each | Iterate the items of a collection |
| eachDay | Iterate the days of a span |
| eachMonth | Iterate the months of a span |
| eachWhile | Iterate the items of a collection until the given function returns non-null |
| echo | Write the str represenation of x to stdout and return x |
| end | End value of a DateSpan, Span, or a range |
| endsWith | Return if Str ends with the specified Str |
| equals | Return if two values are equivalent |
| eval | Evaluate an Axon string expression |
| evalToFunc | Evalate an Axon string expression to a function |
| filter | Apply a filter expression to a collection of dicts |
| filterToFunc | Convert a filter expression to a function which maybe used with findAll() or find() |
| find | Find the first matching item in a list or grid by applying the given filter function |
| findAll | Find all the items in a list, dict, or grid by applying the given filter function |
| first | Get the first item from an ordered collection or return null if the collection is empty |
| firstOfMonth | Get the first day of given date's month |
| flatMap | Map each item in a list or grid to zero or more new items as a flattened result |
| flatten | Flatten a list to a single level |
| fold | Fold a list or stream into a single value using given folding function |
| foldCol | Fold the values of the given column into a single value |
| foldCols | Fold a set of columns in each row into a new folded column and return a new grid |
| foldEnd | The fold end marker value |
| foldStart | The fold start marker value |
| format | Format an object using the current locale and specified format pattern |
| fromJavaMillis | Given Number of milliseconds since Unix epoch return a DateTime |
| func | Find a top-level function by name or by reference and return its tags |
| funcs | Find all the top-levels functions in the current project which match the given filter |
| get | Get an item from a collection |
| getSafe | Get an item from a str, list, or grid safely when an index is out of bounds |
| gridColKinds | Given a grid return the types used in each column as a grid with the following |
| gridColsToDict | Convert grid columns into a dict of name/val pairs |
| gridReplace | Replace every grid cell with the given from value with the to value |
| gridRowsToDict | Convert grid rows into a dict of name/val pairs |
| has | If val is a Grid return if it has the given column name |
| hour | Get hour of day as integer between 0 to 23 from time or datetime |
| hoursInDay | Given a DateTime in a specific timezone, return the number of hours in the day |
| index | Return the first match of x in val searching forward, starting at the specified offset index |
| indexr | Return the last match of x in val searching backward, starting at the specified offset index |
| insert | Insert an item into a list at the given index and return a new list |
| insertAll | Insert a list of items at the given index and return a new list |
| isAlpha | Is number an ASCII alpha char |
| isAlphaNum | Is number an ASCII alpha-numeric char |
| isBool | Return if an object is a boolean type |
| isDate | Return if an object is a Date type |
| isDateTime | Return if an object is a DateTime type |
| isDict | Return if an object is a dict type |
| isDigit | Is number a digit in the specified radix |
| isDuration | Return if an object is a number type with a time unit |
| isEmpty | Return if a collection is empty |
| isEven | Return if an integer is an even number |
| isFunc | Return if an object is a function type |
| isGrid | Return if an object is a grid type |
| isHisGrid | Return if an object is a grid that conforms to the history grid shape |
| isKeyword | Return if given string is an Axon keyword |
| isLeapYear | Return if a year is a leap year |
| isList | Return if an object is a list type |
| isLower | Is number an ASCII lowercase alphabetic char |
| isMetric | Given an optional value return true if the SI metric system should be used |
| isNaN | Return if val is the Number representation of not-a-number |
| isNonNull | Return if an object is not null |
| isNull | Return if an object is null |
| isNumber | Return if an object is a number type |
| isOdd | Return if an integer is an odd number |
| isRef | Return if an object is a ref type |
| isSpace | Is number is whitespace char |
| isSpan | Return if an object is a span |
| isStr | Return if an object is a str type |
| isTagName | Return if the given string is legal tag name - see Etc.isTagName |
| isTime | Return if an object is a Time type |
| isUpper | Is number an ASCII uppercase alphabetic char |
| isUri | Return if an object is a Uri type |
| isWeekday | Does the given Date or DateTime fall on Mon, Tue, Wed, Thu, or Fri |
| isWeekend | Does the given Date or DateTime fall on Sat or Sun |
| join | Join two grids by column name |
| joinAll | Join a list of grids into a single grid |
| keepCols | Return a new grid with keeps the given columns, but removes all the others |
| last | Get the last item from an ordered collection or return null if the collection is empty |
| lastMonth | DateSpan for month previous to this month 1..28-31 |
| lastOfMonth | Get the last day of the date's month |
| lastQuarter | DateSpan for 3 month quarter previous to this quarter |
| lastWeek | DateSpan for week previous to this week sun..sat (uses locale start of week) |
| lastYear | DateSpan for year previous to this year Jan-1..Dec-31 |
| libs | List the lib definitions in the context namespace as Def[] |
| limit | Truncate stream after given limit is reached |
| localeUse | Evaluate an expression within a specific locale |
| lower | Convert a char number or str to ASCII lower case |
| map | Map list, dict, or grid by applying the given mapping function |
| marker | Get the marker value singleton Marker.val |
| max | Compare two numbers and return the larger one |
| merge | Merge two Dicts together and return a new Dict |
| meta | Get the meta-data from a grid or col as a dict |
| min | Compare two numbers and return the smaller one |
| minute | Get minutes of the time as integer between 0 to 59 from time or datetime |
| missing | If val is a Grid return if it does not have given column name |
| month | Get month as integer between 1 to 12 from date or datetime |
| moveTo | Find the given item in a list, and move it to the given index |
| na | Get NA not-available singleton NA.val |
| name | If val is a Col, get the column name |
| names | Get the list of names used by a given dict |
| nan | Return the Number representation of not-a-number |
| negInf | Return the Number representation negative infinity |
| now | Return current DateTime according to context's time zone |
| nowTicks | Return current time as nanosecond ticks since 1 Jan 2000 UTC |
| nowUtc | Return current DateTime in UTC |
| numDays | Number of whole days in a span |
| numDaysInMonth | Get the number of days in a given month |
| occurred | Return if a timestamp is contained within a Date range |
| padl | Pad string to the left |
| padr | Pad string to the right |
| parseAst | Parse Axon source code into an abstract syntax tree modeled as a tree of dicts |
| parseBool | Parse a Str into a Bool, legal formats are "true" or "false |
| parseDate | Parse a Str into a Date |
| parseDateTime | Parse a Str into a DateTime |
| parseFilter | Parse a filter string into a Filter instance |
| parseFloat | Parse a Str into a Float |
| parseInt | Parse a Str into a integer number using the specified radix |
| parseNumber | Parse a Str into a number with an option unit |
| parseRef | Parse a Str into a Ref |
| parseSearch | Parse a search string into a Filter instance |
| parseSymbol | Parse a Str into a Symbol |
| parseTime | Parse a Str into a Time |
| parseUnit | Parse a Str into a standardized unit name |
| parseUri | Parse a string into a Uri instance |
| pastMonth | DateSpan for last 30days today-30days..today |
| pastWeek | DateSpan for last 7 days as today-7days..today |
| pastYear | DateSpan for this past today-365days..today |
| posInf | Return the Number representation positive infinity |
| reFind | Find the first match of regular expression in s or return null if no matches |
| reFindAll | Find all matches of the regular expression in s |
| reGroups | Return a list of the substrings captured by matching the given regular operation against s |
| reMatches | Return if regular expression matches entire region of s |
| reduce | Reduce a collection to a single value with the given reducer function |
| refDis | Given a ref return Ref.dis |
| refGen | Generate a new unique Ref identifier |
| refProjName | Given an absolute ref, return its project name |
| relDis | Get a relative display name |
| remove | Remove an item from a collection and return a new collection |
| removeCol | Return a new grid with the given column removed |
| removeCols | Return a new grid with all the given columns removed |
| removeMarker | Get the remove value singleton Remove.val |
| renameCol | Return a new grid with the given column renamed |
| renameCols | Return a new grid with multiple columns renamed |
| reorderCols | Return a new grid with the columns reordered |
| replace | String replace of all occurrences of from with to |
| rowToList | Get a grid row as a list of cells |
| second | Get seconds of the time as integer between 0 to 59 from time or datetime |
| set | Set a collection item and return a new collection |
| setColMeta | Return a new grid with column meta-data replaced by given meta dict |
| setMeta | Return new grid with grid level meta-data replaced by given meta Dict |
| size | Return number of items in str, list, or grid |
| skip | Skip the given number of items in a stream |
| sort | Sort a list or grid |
| sortDis | Sort a grid by row display name - see Grid.sortDis Examples |
| sortr | Reverse sort a list or grid |
| split | Split a string by the given separator and trim whitespace |
| spread | Fold multiple values to compute the difference between the max and min value |
| start | Start value of a DateSpan, Span or a range |
| startOfWeek | Return current locale's start of weekday |
| startsWith | Return if Str starts with the specified Str |
| stream | Create new stream from given collection |
| streamCol | Create a new stream for the cell values of the given column |
| sum | Fold multiple values into their numeric sum |
| swizzleRefs | Given a grid of records, assign new ids and swizzle all internal ref tags |
| tags | List tag definitions in the context namespace as Def[] |
| terms | List term definitions (tags and conjuncts) in the context namespace as Def[] |
| thisMonth | DateSpan for this month as 1st..28-31 |
| thisQuarter | DateSpan for this 3 month quarter |
| thisWeek | DateSpan for this week as sun..sat (uses locale start of week) |
| thisYear | DateSpan for this year Jan-1..Dec-31 |
| time | If val is a DateTime |
| times | Call the specified function the given number of times passing the counter |
| to | Convert a number to the given unit |
| toAxonCode | Convert a scalar, list, or dict value to its Axon code representation |
| toChar | Convert a unicode char number into a single char string Examples |
| toDateSpan | Convert the following objects into a DateSpan |
| toGrid | Given an arbitrary object, translate it to a Grid via Etc.toGrid |
| toHex | Convert a number to a hexadecimal string |
| toJavaMillis | Given a DateTime return Number of milliseconds since Unix epoch |
| toList | If val is a list return it, otherwise return [val] |
| toLocale | Get the localized string for the given tag name or qualified name |
| toRadix | Convert a number to its string representation in the given radix (base) |
| toSpan | Convert the following objects into a Span |
| toStr | Convert an obj to its string representation |
| toTagName | Given arbitrary string, convert to a safe tag name - see Etc.toTagName |
| toTimeZone | Convert a DateTime or Span to another timezone |
| today | Return today's Date according to context's time zone |
| transpose | Perform a matrix transpose on the grid |
| trap | Function for the -> operator |
| trim | Trim whitespace from the beginning and end of the string |
| trimEnd | Trim whitespace only from the end of the string |
| trimStart | Trim whitespace only from the beginning of the string |
| tz | Get timezone as city name string in tzinfo database from datetime |
| unique | Return the unique items in a collection |
| unit | Given a number return its unit string or null |
| unitsEq | Return if the two numbers have the same unit |
| upper | Convert a char number or str to ASCII upper case |
| uriBasename | Get the basename (last name in path without extension) of a Uri as a string |
| uriDecode | Parse an ASCII percent encoded string into a Uri according to RFC 3986 |
| uriEncode | Return the percent encoded string for this Uri according to RFC 3986 |
| uriExt | Get the URI extension of a Uri as a string or null |
| uriFrag | Return if the fragment identifier portion of the a URI after hash symbol |
| uriHost | Get the host Uri as a string or null |
| uriIsDir | Return if the URI path ends in a slash |
| uriName | Get the name Str of a Uri (last item in path) |
| uriPath | Get the path segments of a Uri as a list of Strs |
| uriPathStr | Get the path a Uri as a string |
| uriPlusSlash | Adding trailing slash to the URI |
| uriPort | Get the port of a Uri as a Number or null |
| uriQueryStr | Return if the query portion of the a URI after question mark |
| uriScheme | Get the scheme of a Uri as a string or null |
| vals | Get the list of values used by a given dict |
| weekOfYear | Given a DateTime or Date, return the week number of the year |
| weekday | Get weekday as integer from 0 to 6 of Date or DateTime |
| xstr | Construct decoded XStr instance |
| year | Get year as integer such as 2010 from date or datetime |
| yesterday | Return yesterday's Date according to context's time zone |
def
admin
Requires admin permission
meta
| def | admin |
| is | marker |
| lib | lib:axon |
| tagOn | finSetting, func, view |
supertypes
| marker | Marker labels a dict with typing information |
def
disableOverridableChecks
Disables function overridable checking.
meta
| def | disableOverridableChecks |
| is | marker |
| lib | lib:axon |
supertypes
| marker | Marker labels a dict with typing information |
def
err
Indicates an error condition, dis should contain display message. Also see errTrace
meta
| def | err |
| is | marker |
| lib | lib:axon |
supertypes
| marker | Marker labels a dict with typing information |
def
errTrace
Exception stack trace
meta
| def | errTrace |
| is | str |
| lib | lib:axon |
| multiLine | ✓ |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
def
expr
Axon expression string
meta
| def | expr |
| is | str |
| lib | lib:axon |
| uiInput | ui::AxonInput |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
subtypes
| taskExpr | Task messaging handling Axon expression |
def
foldOn
Registers a function as folding a given value type
meta
| def | foldOn |
| is | str |
| lib | lib:axon |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
def
func
Axon function
meta
| def | func |
| icon | func |
| is | feature |
| lib | lib:axon |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
tags
| admin | Requires admin permission |
| dis | Display name for an entity |
| doc | Documentation in simplified flavor of markdown |
| help | End user documentation |
| ruleOn | Target filter for a rule or rule ready func |
| ruleType | Rule type choice |
| su | Requires superuser permission |
def
func:abs
abs(val)
Return absolute value of a number, if null return null
meta
| def | func:abs |
| is | func |
| lib | lib:axon |
| name | abs |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:add
add(val, item)
Add item to the end of a list and return a new list.
meta
| def | func:add |
| is | func |
| lib | lib:axon |
| name | add |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:addAll
addAll(val, items)
Add all the items to the end of a list and return a new list.
meta
| def | func:addAll |
| is | func |
| lib | lib:axon |
| name | addAll |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:addCol
addCol(grid, col, fn)
Add a column to a grid by mapping each row to a new cell value. The col parameter may be a simple String name or may be a dictionary which must have a "name" tag (any other tags become column meta-data). The mapping function takes (row) and returns the new cell values for the column.
Examples:
// add new column named areaMeter
readAll(site).addCol("areaMeters") s => s->area.to(1m²)
// add new column named areaMeter with dis meta
readAll(site).addCol({name:"areaMeters", dis:"Area Meters"}) s => s->area.to(1m²)meta
| def | func:addCol |
| is | func |
| lib | lib:axon |
| name | addCol |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:addColMeta
addColMeta(grid, name, meta)
Return a new grid with additional column meta-data. If column not found, then return given grid. Column meta is added using merge() conventions. Also see setColMeta() and Streams.
meta
| def | func:addColMeta |
| is | func |
| lib | lib:axon |
| name | addColMeta |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:addCols
addCols(a, b)
Add grid b as a new set of columns to grid a. If b contains duplicate column names, then they are given auto-generated unique names. If b contains fewer rows then a, then the missing cells are filled with null.
Examples:
[{a:0, b:2}, {a:1, b:3}].toGrid.addCols({c:4}.toGrid)
readAll(rtu).addCols(readAll(meter))meta
| def | func:addCols |
| is | func |
| lib | lib:axon |
| name | addCols |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:addMeta
addMeta(grid, meta)
Return new grid with additional grid level meta-data tags. Tags are added using merge() conventions. Also see setMeta() and Streams.
Example:
read(temp).hisRead(today).addMeta({view:"table"})meta
| def | func:addMeta |
| is | func |
| lib | lib:axon |
| name | addMeta |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:addRow
addRow(grid, newRow)
Add an additional Dict row to the end of a grid.
Example:
readAll(site).addRow({dis:"New Row"})meta
| def | func:addRow |
| is | func |
| lib | lib:axon |
| name | addRow |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:addRows
addRows(grid, newRows)
Add an list of rows to the end of a grid. The newRows may be expressed as list of Dict or a Grid.
Example:
readAll(site).addRows(readAll(equip))meta
| def | func:addRows |
| is | func |
| lib | lib:axon |
| name | addRows |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:all
all(val, fn)
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, 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.
If working with a string, the function takes (char) or (char, index) and returns true or false.
If working with a stream, then function takes (val) and returns true or false. See Streams.
Examples:
[1, 3, 5].all v => v.isOdd >> true
[1, 3, 6].all(isOdd) >> falsemeta
| def | func:all |
| is | func |
| lib | lib:axon |
| name | all |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func: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.
If working with a string, the function takes (char) or (char, index) and returns true or false.
If working with a stream, then function takes (val) and returns true or false. See Streams.
Examples:
[1, 3, 5].any v => v.isOdd >> true
[2, 4, 6].any(isOdd) >> falsemeta
| def | func:any |
| is | func |
| lib | lib:axon |
| name | any |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:as
as(val, unit)
Set the unit of a number. Unlike to() function, 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).
Examples:
75°F.as(1°C)
75°F.as("°C")meta
| def | func:as |
| is | func |
| lib | lib:axon |
| name | as |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func: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.
Example:
[7, 2, 3].fold(avg) >> 4meta
| def | func:avg |
| disKey | ui::average |
| foldOn | Number |
| is | func |
| lib | lib:axon |
| name | avg |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:call
call(func, args: null)
Reflectively call a function with the given arguments. The func may be a Str name or an expression that evaluates to a function. Args is a positional list for each argument. Examples:
call("today")
call("replace", ["hi there", "hi", "hello"])
call("parseDate", ["2021-03-15"])
call("parseDate", ["15-Mar-21", "DD-MMM-YY"])
call(parseDate, ["15-Mar-21", "DD-MMM-YY"])
call(parseDate(_, "DD-MMM-YY"), ["15-Mar-21"])meta
| def | func:call |
| is | func |
| lib | lib:axon |
| name | call |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:capitalize
capitalize(val)
Return this string with the first character converted to uppercase. The case conversion is for ASCII only. Also see decapitalize() and upper().
Examples:
capitalize("apple") >> "Apple"meta
| def | func:capitalize |
| is | func |
| lib | lib:axon |
| name | capitalize |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:clamp
clamp(val, min, max)
Clamp the number val between the min and max. If its less than min then return min, if its greater than max return max, otherwise return val itself. The min and max must have matching units or be unitless. The result is always in the same unit as val.
Examples:
14.clamp(10, 20) >> 14 // is between 10 and 20
3.clamp(10, 20) >> 10 // clamps to min 10
73.clamp(10, 20) >> 20 // clamps to max 20
45°F.clamp(60, 80) >> 60°F // min/max can be unitlessmeta
| def | func:clamp |
| is | func |
| lib | lib:axon |
| name | clamp |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func: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.
Example:
// get meta data for given columm
read(temp).hisRead(today).col("ts").metameta
| def | func:col |
| is | func |
| lib | lib:axon |
| name | col |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:colNames
colNames(grid)
Get the column names a list of strings.
Example:
readAll(site).colNamesmeta
| def | func:colNames |
| is | func |
| lib | lib:axon |
| name | colNames |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:colToList
colToList(grid, col)
Get a column as a list of the cell values ordered by row. Also see rowToList().
Example:
readAll(site).colToList("dis")meta
| def | func:colToList |
| is | func |
| lib | lib:axon |
| name | colToList |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:collect
collect(stream, to: null)
Collect stream into a in-memory list or grid. See Streams.
meta
| def | func:collect |
| is | func |
| lib | lib:axon |
| name | collect |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:cols
cols(grid)
Get the columns from a grid as a list.
Example:
// get name of first column
readAll(site).cols.first.namemeta
| def | func:cols |
| is | func |
| lib | lib:axon |
| name | cols |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:colsToLocale
colsToLocale(grid)
Localize column display names. For each col which does not have an explicit dislay name, add a dis tag based on the column name. Also see Grid.colsToLocale and Localization.
meta
| def | func:colsToLocale |
| is | func |
| lib | lib:axon |
| name | colsToLocale |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:compDef
compDef(name, checked: true)
Return component definition. The result is a grid where each row corresponds to a cell and its associated meta data. The grid meta is the function level meta data.
Example:
compDef("compName")meta
| def | func:compDef |
| is | func |
| lib | lib:axon |
| name | compDef |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func: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"meta
| def | func:concat |
| is | func |
| lib | lib:axon |
| name | concat |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:conjuncts
conjuncts()
List conjunct definitions in the context namespace as Def[].
meta
| def | func:conjuncts |
| is | func |
| lib | lib:axon |
| name | conjuncts |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:contains
contains(val, x)
Return if val contains x:
- if
valis Str, thenxis substring. - if
valis List, thenxis item to search. - if
valis Range, then isxinside the range inclusively - if
valis DateSpan, then isxa date in the span
meta
| def | func:contains |
| is | func |
| lib | lib:axon |
| name | contains |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:coord
coord(lat, lng)
Construct a Coord from two Numbers in decimal degrees
meta
| def | func:coord |
| is | func |
| lib | lib:axon |
| name | coord |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:coordDist
coordDist(c1, c2)
Compute the great-circle distance between two Coords. The result is a distance in meters using the haversine forumula.
meta
| def | func:coordDist |
| is | func |
| lib | lib:axon |
| name | coordDist |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:coordLat
coordLat(coord)
Latitude of a Coord as a Number
meta
| def | func:coordLat |
| is | func |
| lib | lib:axon |
| name | coordLat |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:coordLng
coordLng(coord)
Longitude of a Coord as a Number
meta
| def | func:coordLng |
| is | func |
| lib | lib:axon |
| name | coordLng |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:count
count(val, acc)
Fold multiple values into their total count Return zero if no values.
meta
| def | func:count |
| foldOn | Obj |
| is | func |
| lib | lib:axon |
| name | count |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:curFunc
curFunc()
Get the current top-level function's tags.
meta
| def | func:curFunc |
| is | func |
| lib | lib:axon |
| name | curFunc |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:date
date(val, month: null, day: null)
If val is a DateTime: get date portion of the timestamp. If val is a Number: construct a date instance from year, month, day
Examples:
now().date // same as today()
date(2010, 12, 1) // same as 2010-12-01meta
| def | func:date |
| is | func |
| lib | lib:axon |
| name | date |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:dateTime
dateTime(d, t, tz: null)
Construct a DateTime from a date, time, and timezone name. If timezone is null, use system default.
meta
| def | func:dateTime |
| is | func |
| lib | lib:axon |
| name | dateTime |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:day
day(d)
Get day of month as integer between 1 to 31 from date or datetime.
meta
| def | func:day |
| is | func |
| lib | lib:axon |
| name | day |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:dayOfYear
dayOfYear(val)
Given a DateTime or Date, return the day of the year. The result is a number between 1 and 365 (or 1 to 366 if a leap year).
meta
| def | func:dayOfYear |
| is | func |
| lib | lib:axon |
| name | dayOfYear |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:debugType
debugType(val)
Return a string of the given value's type. No guarantee is made for the string's format. Applications must not assume any specific format, this function is for human consumption only.
meta
| def | func:debugType |
| is | func |
| lib | lib:axon |
| name | debugType |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:decapitalize
decapitalize(val)
Return this string with the first character converted to lowercase. The case conversion is for ASCII only. Also see capitalize() and lower().
Examples:
decapitalize("Apple") >> "apple"meta
| def | func:decapitalize |
| is | func |
| lib | lib:axon |
| name | decapitalize |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:def
def(symbol, checked: true)
Lookup a def by its symbol name (Str or Symbol). If not found return null or raise UnknownDefErr based on checked flag. The result is returned as the definition's normalized dict representation.
meta
| def | func:def |
| is | func |
| lib | lib:axon |
| name | def |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:defs
defs()
List all definitions in the context namespace as Def[].
meta
| def | func:defs |
| is | func |
| lib | lib:axon |
| name | defs |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:dis
dis(dict, name: null, def: "")
Get display string for dict or the given tag. If name is null, then return display text for the entire dict using Etc.dictToDis. If name is non-null then format the tag value using its appropiate toLocale method. Also see Dict.dis.
meta
| def | func:dis |
| is | func |
| lib | lib:axon |
| name | dis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:dst
dst(dt)
Return if a DateTime is in daylight saving time. For the given DateTime and its specific timezone, return true if the time is in daylight savings time or false if standard time.
meta
| def | func:dst |
| is | func |
| lib | lib:axon |
| name | dst |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:each
each(val, fn)
Iterate the items of a collection:
- Grid: iterate the rows as (row, index)
- List: iterate the items as (value, index)
- Dict: iterate the name/value pairs (value, name)
- Str: iterate the characters as numbers (char, index)
- Range: iterate the integer range (integer)
- Stream: iterate items as (val); see Streams
meta
| def | func:each |
| is | func |
| lib | lib:axon |
| name | each |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:eachDay
eachDay(dates, fn)
Iterate the days of a span. The dates argument may be any object converted into a date range by toDateSpan(). The given function is called with a Date argument for each iterated day.
Example:
f: day => echo(day)
eachDay(2010-07-01..2010-07-03, f) >> iterate Jul 1st, 2nd, 3rd
eachDay(2010-07, f) >> iterate each day of July 2010
eachDay(pastWeek, f) >> iterate last 7 daysmeta
| def | func:eachDay |
| is | func |
| lib | lib:axon |
| name | eachDay |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:eachMonth
eachMonth(dates, fn)
Iterate the months of a span. The dates argument may be any object converted into a date range by toDateSpan(). The given function is called with a DateSpan argument for each interated month.
Examples:
// iterate each month in 2010, and echo data range
eachMonth(2010) d => echo(d)
// call f once for current method
eachMonth(today(), f)meta
| def | func:eachMonth |
| is | func |
| lib | lib:axon |
| name | eachMonth |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:eachWhile
eachWhile(val, fn)
Iterate the items of a collection until the given function returns non-null. Once non-null is returned, then break the iteration and return the resulting object. Return null if the function returns null for every item.
- Grid: iterate the rows as (row, index)
- List: iterate the items as (val, index)
- Dict: iterate the name/value pairs (val, name)
- Str: iterate the characters as numbers (char, index)
- Range: iterate the integer range (integer)
- Stream: iterate items as (val); see Streams
meta
| def | func:eachWhile |
| is | func |
| lib | lib:axon |
| name | eachWhile |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:echo
echo(x)
Write the str represenation of x to stdout and return x.
meta
| admin | ✓ |
| def | func:echo |
| is | func |
| lib | lib:axon |
| name | echo |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:end
end(val)
End value of a DateSpan, Span, or a range.
meta
| def | func:end |
| is | func |
| lib | lib:axon |
| name | end |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:endsWith
endsWith(val, sub)
Return if Str ends with the specified Str.
Examples:
"hi there".endsWith("there") >> true
"hi there".endsWith("hi") >> falsemeta
| def | func:endsWith |
| is | func |
| lib | lib:axon |
| name | endsWith |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:equals
equals(a, b)
Return if two values are equivalent. Unlike the standard == operator this function will compare the contents of collection values such as lists, dicts, and grids. For non-collection values, the result is the same as the == operator. This function does not work with lazy grids such as hisRead result.
meta
| def | func:equals |
| is | func |
| lib | lib:axon |
| name | equals |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:eval
eval(expr)
Evaluate an Axon string expression. The evaluation happens in a new scope and does not have access to the current scope of local variables. Also see call() and toAxonCode().
Examples:
eval("2 + 2")
eval("now()")meta
| def | func:eval |
| is | func |
| lib | lib:axon |
| name | eval |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:evalToFunc
evalToFunc(expr)
Evalate an Axon string expression to a function. Typically the expression is just a function name, but it can be any expression that evaluates to a function. Raise an exception if the expression does not evaluate to a function. Note this call does evalute the given expression in the runtime, so it must be used with caution - never use it with a string from a non-trusted origin.
Examples:
evalToFunc("now").call
evalToFunc("(x, y)=>x+y").call([3, 4])
(evalToFunc("(x, y)=>x+y"))(3, 4)
evalToFunc("""replace(_, "x", "_")""").call(["xyz"])meta
| def | func:evalToFunc |
| is | func |
| lib | lib:axon |
| name | evalToFunc |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:filter
filter(val, filterExpr)
Apply a filter expression to a collection of dicts. The collection value may be any of the following:
- Grid: returns new grid with filtered rows
- Dict[]: returns list of filtered dicts (nulls are filtered out)
- Col[]: returns list of columns filtered by their meta
- Stream: filters stream of Dicts - see Streams
The filter parameter may one fo the following:
- Axon expression which maps to a filter
- Filter from
parseFilter() - Filter from
parseSearch()
Examples:
// apply to a list of dicts
[{v:1}, {v:2}, {v:3}, {v:4}].filter(v >= 3)
// apply to a grid and return new grid with matching rows
readAll(equip).filter(meter)
// apply to a list of columns
read(ahu).toPoints.hisRead(yesterday).cols.filter(kind=="Bool")
// apply to a stream of dicts
readAllStream(equip).filter(siteMeter and elec and meter).collect
// apply search filter
readAll(equip).filter(parseSearch("RTU-1"))meta
| def | func:filter |
| is | func |
| lib | lib:axon |
| name | filter |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:filterToFunc
filterToFunc(filterExpr)
Convert a filter expression to a function which maybe used with findAll() or find(). The returned function accepts one Dict parameter and returns true/false if the Dict is matched by the filter. Also see filter() and parseFilter().
Examples:
// filter for dicts with 'equip' tag
list.findAll(filterToFunc(equip))
// filter rows with an 'area' tag over 10,000
grid.findAll(filterToFunc(area > 10_000))meta
| def | func:filterToFunc |
| is | func |
| lib | lib:axon |
| name | filterToFunc |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:find
find(val, fn)
Find the first matching item in a list or grid by applying the given filter function. If no match is found return null.
If working with a list, the filter should be a function that takes (val) or (val, index). It should return true to match and return the item.
If working with a dict, the filter should be a function that takes (val) or (val, name). It should return true to match and return the item.
If working with a grid, the filter function takes (row) or (row, index) and returns true to match and return the row.
If working with a stream, the filter takes (val) and returns true to match. See Streams.
Examples:
// find first string longer than 3 chars
["ape", "bat", "charlie", "dingo"].find(x => x.size > 3)
// find first odd number
[10, 4, 3, 7].find(isOdd)meta
| def | func:find |
| is | func |
| lib | lib:axon |
| name | find |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:findAll
findAll(val, fn)
Find all the items in a list, dict, or grid by applying the given filter function. Also see find().
If working with a list, the filter should be a function that takes (val) or (val, index). It should return true to keep the item.
If working with a dict, the filter should be a function that takes (val) or (val, name). It should return the true to keep the name/value pair.
If working with a grid, the filter function takes (row) or (row, index) and returns true to keep the row. The resulting grid shares the original's grid meta and columns.
If working with a stream, the filter takes (val) and returns true to match. See Streams.
Examples:
// find all the strings longer than 3 chars
["ape", "bat", "charlie", "dingo"].findAll(x => x.size > 3)
// find even numbers
[0, 1, 2, 3, 4].findAll(isEven)
// find all the sites greater than 10,000ft from grid
readAll(site).findAll(s => s->area > 10_000ft²)meta
| def | func:findAll |
| is | func |
| lib | lib:axon |
| name | findAll |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:first
first(val)
Get the first item from an ordered collection or return null if the collection is empty:
- list: item at index 0
- grid: first frow
- stream: first item; see Streams
meta
| def | func:first |
| is | func |
| lib | lib:axon |
| name | first |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:firstOfMonth
firstOfMonth(date)
Get the first day of given date's month. Also see lastOfMonth().
Example:
2009-10-28.firstOfMonth >> 2009-10-01meta
| def | func:firstOfMonth |
| is | func |
| lib | lib:axon |
| name | firstOfMonth |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:flatMap
flatMap(val, fn)
Map each item in a list or grid to zero or more new items as a flattened result.
If mapping a list, the mapping should be a function that takes (val) or (val, index). It should return the a list of zero or more new values. See List.flatMap.
If mapping a grid, the mapping function takes (row) or (row,index) and returns a list of zero or more new Dict rows. See Grid.flatMap.
If mapping a stream, the mapping functions takes (val). See Streams.
Examples:
[1, 2, 3].flatMap(v => [v, v+10]) >> [1, 11, 2, 12, 3, 13]meta
| def | func:flatMap |
| is | func |
| lib | lib:axon |
| name | flatMap |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:flatten
flatten(list)
Flatten a list to a single level. If given a list of grids, then flatten rows to a single grid. Also see List.flatten and Etc.gridFlatten.
Examples:
// flatten a list of numbers
[1, [2, 3], [4, [5, 6]]].flatten >> [1, 2, 3, 4, 5, 6]
// flatten a list of grids
["Carytown", "Gaithersburg"].map(n=>readAll(siteRef->dis==n)).flattenmeta
| def | func:flatten |
| is | func |
| lib | lib:axon |
| name | flatten |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:fold
fold(val, fn)
Fold a list or stream into a single value using given folding function. The folding function signature must be (val, acc) where val is the items being folded, and acc is an accumulator used to maintain state between iterations. Lifecycle of a fold:
- Call
fn(foldStart, null), return initial accumulator state - Call
fn(item, acc)for every item, return new accumulator state - Call
fn(foldEnd, acc)return final result
See Streams for streaming details.
The fold will short-circuit and halt immediately if the folding function returns na() for the accumulator state. The result of the fold is na() in this case. A folding function should document its behavior when a collection contains na().
Built-in folding functions include:
Examples:
[1, 2, 3, 4].fold(max) // fold list into its max value
[1, 2, 3, 4].fold(avg) // fold list into its average value
[1, 2, na(), 3].fold(sum) // => na()Example of writing your own custom fold function that used start/end values and has support for na():
average: (val, acc) => do
if (val == foldStart()) return {sum:0, count:0}
if (val == foldEnd()) return acc->sum / acc->count
if (val == na()) return na()
return {sum: acc->sum + val, count: acc->count + 1}
endAlso see reduce() which is easier to use if doing your own simple rollup computation.
meta
| def | func:fold |
| is | func |
| lib | lib:axon |
| name | fold |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:foldCol
foldCol(grid, colName, fn)
Fold the values of the given column into a single value. The folding function uses the same semantics as fold().
Example:
readAll(site).foldCol("area", sum)meta
| def | func:foldCol |
| is | func |
| lib | lib:axon |
| name | foldCol |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:foldCols
foldCols(grid, colSelector, newColName, fn)
Fold a set of columns in each row into a new folded column and return a new grid. The columns to fold are selected by the colSelector function and removed from the result. The selector may be a list of string names or a function which takes a Col and returns true to select it. The folding function uses same semantics as fold().
Example:
// consider grid 'g' with the following structure:
a b c
--- --- ---
1 10 100
2 20 200
// foldCols, add b and c together to create new bc column
g.foldCols(["b", "c"], "bc", sum)
// yields this grid:
a bc
--- ---
1 110
2 220
// we could also replace list of col names with a function
colSel: col => col.name == "b" or col.name == "c"
g.foldCols(colSel, "bc", sum)meta
| def | func:foldCols |
| is | func |
| lib | lib:axon |
| name | foldCols |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:foldEnd
foldEnd()
The fold end marker value
meta
| def | func:foldEnd |
| is | func |
| lib | lib:axon |
| name | foldEnd |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:foldStart
foldStart()
The fold start marker value
meta
| def | func:foldStart |
| is | func |
| lib | lib:axon |
| name | foldStart |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:format
format(val, pattern: null)
Format an object using the current locale and specified format pattern. Formatting patterns follow Fantom toLocale conventions:
Bool.toLocaleNumber.toLocaleDate.toLocaleTime.toLocaleDateTime.toLocaleIftoLocalemethod is found, then returnval.toStr
Examples:
123.456kW.format >> 123kW
123.456kW.format("#.0") >> 123.5kW
today().format("D-MMM-YYYY") >> 8-Feb-2023
today().format("DDD MMMM YYYY") >> 8th February 2023
now().format("D-MMM hh:mm") >> 08-Feb 14:50
now().format("DD/MM/YY k:mmaa") >> 08/02/23 2:50pmmeta
| def | func:format |
| is | func |
| lib | lib:axon |
| name | format |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:fromJavaMillis
fromJavaMillis(millis, tz: null)
Given Number of milliseconds since Unix epoch return a DateTime. The epic is defined as 1-Jan-1970 UTC. If timezone is null, use system default. Also see toJavaMillis().
meta
| def | func:fromJavaMillis |
| is | func |
| lib | lib:axon |
| name | fromJavaMillis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:func
func(name, checked: true)
Find a top-level function by name or by reference and return its tags. If not found throw exception or return null based on checked flag.
Example:
func("readAll")
func(readAll)meta
| def | func:func |
| is | func |
| lib | lib:axon |
| name | func |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:funcs
funcs(filterExpr: null)
Find all the top-levels functions in the current project which match the given filter. If the filter is omitted then return all the functions declared in the current project. The function tags are returned.
Examples:
funcs() // all functions
funcs(sparkRule) // match filtermeta
| def | func:funcs |
| is | func |
| lib | lib:axon |
| name | funcs |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:get
get(val, key)
Get an item from a collection:
- str(num): get character at index as int (same semantics as Fantom)
- str(range): get string slice (same semantics as Fantom)
- list(num): get item at given index (same semantics as Fantom)
- list(range): get list slice at given index (same semantics as Fantom)
- dict(key): get item with given key or return null
- grid(num): get row at given index
- grid(range):
Grid.getRange
The get function maybe be accessed using the [] shortcut operator:
list[3] >> list.get(3)See Axon Language.
meta
| def | func:get |
| is | func |
| lib | lib:axon |
| name | get |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:getSafe
getSafe(val, key)
Get an item from a str, list, or grid safely when an index is out of bounds:
- str(num): get a character at index or null if index invalid
- str(range): get safe slice or "" if entire range invalid
- list(num): get item at given index or null is index invalid
- list(range): get list slice with safe index
- grid(num): get row at given index or null if index invalid
- grid(range):
Grid.getRangewith safe range
meta
| def | func:getSafe |
| is | func |
| lib | lib:axon |
| name | getSafe |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:gridColKinds
gridColKinds(grid)
Given a grid return the types used in each column as a grid with the following:
name: string name of the columnkind: all the different value kinds in the column separated by "|"count: total number of rows with column with a non-null value Also seereadAllTagNames().
Example:
readAll(site).gridColKindsmeta
| def | func:gridColKinds |
| is | func |
| lib | lib:axon |
| name | gridColKinds |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:gridColsToDict
gridColsToDict(grid, colToKey, colToVal)
Convert grid columns into a dict of name/val pairs. The name/val paris are derived from each column using the given functions. The functions take (col, index)
Example:
// create dict of column name to column dis
read(temp).hisRead(today).gridColsToDict(c=>c.name, c=>c.meta.dis)meta
| def | func:gridColsToDict |
| is | func |
| lib | lib:axon |
| name | gridColsToDict |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:gridReplace
gridReplace(grid, from, to)
Replace every grid cell with the given from value with the to value. The resulting grid has the same grid and col meta. Replacement comparison is by via equality via == operator, so it will only replace scalar values or null.
Example:
grid.gridReplace(null, 0) // replace all null cells with zero
grid.gridReplace(na(), 0) // replace all NA cells with zerometa
| def | func:gridReplace |
| is | func |
| lib | lib:axon |
| name | gridReplace |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:gridRowsToDict
gridRowsToDict(grid, rowToKey, rowToVal)
Convert grid rows into a dict of name/val pairs. The name/value pairs are derived from each row using the given functions. The functions take (row, index)
Example:
// create dict of sites with dis:area pairs
readAll(site).gridRowsToDict(s=>s.dis.toTagName, s=>s->area)meta
| def | func:gridRowsToDict |
| is | func |
| lib | lib:axon |
| name | gridRowsToDict |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:has
has(val, name)
If val is a Grid return if it has the given column name. If val is a Dict return if the given name is mapped to a non-null value.
meta
| def | func:has |
| is | func |
| lib | lib:axon |
| name | has |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:hour
hour(t)
Get hour of day as integer between 0 to 23 from time or datetime
meta
| def | func:hour |
| is | func |
| lib | lib:axon |
| name | hour |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:hoursInDay
hoursInDay(dt)
Given a DateTime in a specific timezone, return the number of hours in the day. Dates which transition to DST will be 23 hours and days which transition back to standard time will be 25 hours.
meta
| def | func:hoursInDay |
| is | func |
| lib | lib:axon |
| name | hoursInDay |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:index
index(val, x, offset: 0)
Return the first match of x in val searching forward, starting at the specified offset index. A negative offset may be used to access from the end of string. Return null if no occurences are found:
- if
valis Str, thenxis substring. - if
valis List, thenxis item to search.
meta
| def | func:index |
| is | func |
| lib | lib:axon |
| name | index |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:indexr
indexr(val, x, offset: Number.negOne)
Return the last match of x in val searching backward, starting at the specified offset index. A negative offset may be used to access from the end of string. Return null if no occurences are found:
- if
valis Str, thenxis substring. - if
valis List, thenxis item to search.
meta
| def | func:indexr |
| is | func |
| lib | lib:axon |
| name | indexr |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:insert
insert(val, index, item)
Insert an item into a list at the given index and return a new list.
meta
| def | func:insert |
| is | func |
| lib | lib:axon |
| name | insert |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:insertAll
insertAll(val, index, items)
Insert a list of items at the given index and return a new list.
meta
| def | func:insertAll |
| is | func |
| lib | lib:axon |
| name | insertAll |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isAlpha
isAlpha(num)
Is number an ASCII alpha char: isUpper||isLower
Examples:
isAlpha("A".get(0)) >> true
isAlpha("a".get(0)) >> true
isAlpha("8".get(0)) >> false
isAlpha(" ".get(0)) >> false
isAlpha("Ã".get(0)) >> falsemeta
| def | func:isAlpha |
| is | func |
| lib | lib:axon |
| name | isAlpha |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isAlphaNum
isAlphaNum(num)
Is number an ASCII alpha-numeric char: isAlpha||isDigit
Examples:
isAlphaNum("A".get(0)) >> true
isAlphaNum("a".get(0)) >> true
isAlphaNum("8".get(0)) >> true
isAlphaNum(" ".get(0)) >> false
isAlphaNum("Ã".get(0)) >> falsemeta
| def | func:isAlphaNum |
| is | func |
| lib | lib:axon |
| name | isAlphaNum |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isBool
isBool(val)
Return if an object is a boolean type
meta
| def | func:isBool |
| is | func |
| lib | lib:axon |
| name | isBool |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isDate
isDate(val)
Return if an object is a Date type
meta
| def | func:isDate |
| is | func |
| lib | lib:axon |
| name | isDate |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isDateTime
isDateTime(val)
Return if an object is a DateTime type
meta
| def | func:isDateTime |
| is | func |
| lib | lib:axon |
| name | isDateTime |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isDict
isDict(val)
Return if an object is a dict type
meta
| def | func:isDict |
| is | func |
| lib | lib:axon |
| name | isDict |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isDigit
isDigit(num, radix: 10)
Is number a digit in the specified radix. A decimal radix of ten returns true for 0-9. A radix of 16 also returns true for a-f and A-F.
Examples:
isDigit("5".get(0)) >> true
isDigit("A".get(0)) >> false
isDigit("A".get(0), 16) >> truemeta
| def | func:isDigit |
| is | func |
| lib | lib:axon |
| name | isDigit |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isDuration
isDuration(val)
Return if an object is a number type with a time unit
meta
| def | func:isDuration |
| is | func |
| lib | lib:axon |
| name | isDuration |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isEmpty
isEmpty(val)
Return if a collection is empty: str, list, dict, or grid
meta
| def | func:isEmpty |
| is | func |
| lib | lib:axon |
| name | isEmpty |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isEven
isEven(val)
Return if an integer is an even number.
meta
| def | func:isEven |
| is | func |
| lib | lib:axon |
| name | isEven |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isFunc
isFunc(val)
Return if an object is a function type
meta
| def | func:isFunc |
| is | func |
| lib | lib:axon |
| name | isFunc |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isGrid
isGrid(val)
Return if an object is a grid type
meta
| def | func:isGrid |
| is | func |
| lib | lib:axon |
| name | isGrid |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isHisGrid
isHisGrid(val)
Return if an object is a grid that conforms to the history grid shape
meta
| def | func:isHisGrid |
| is | func |
| lib | lib:axon |
| name | isHisGrid |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isKeyword
isKeyword(val)
Return if given string is an Axon keyword
meta
| def | func:isKeyword |
| is | func |
| lib | lib:axon |
| name | isKeyword |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isLeapYear
isLeapYear(year)
Return if a year is a leap year. Year must be four digit Number such as 2020.
meta
| def | func:isLeapYear |
| is | func |
| lib | lib:axon |
| name | isLeapYear |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isList
isList(val)
Return if an object is a list type
meta
| def | func:isList |
| is | func |
| lib | lib:axon |
| name | isList |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isLower
isLower(num)
Is number an ASCII lowercase alphabetic char: a-z
Examples:
isUpper("a".get(0)) >> true
isUpper("A".get(0)) >> false
isUpper("5".get(0)) >> falsemeta
| def | func:isLower |
| is | func |
| lib | lib:axon |
| name | isLower |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isMetric
isMetric(val: null)
Given an optional value return true if the SI metric system should be used. Return false if the United States customary unit system should be used. The following rules are used:
- if val is a dict with
geoCountryreturn return false if "US" - if number or rec with
unitand unit is known to be a US customary unit return false (right now we only check for °F and Δ°F) - fallback to locale of hosting server, see
Locale
Examples:
isMetric({geoCountry:"US"}) >> false
isMetric({geoCountry:"FR"}) >> true
isMetric(75°F) >> false
isMetric({unit:"Δ°C"}) >> true
isMetric() >> fallback to server localemeta
| def | func:isMetric |
| is | func |
| lib | lib:axon |
| name | isMetric |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isNaN
isNaN(val)
Return if val is the Number representation of not-a-number
meta
| def | func:isNaN |
| is | func |
| lib | lib:axon |
| name | isNaN |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isNonNull
isNonNull(val)
Return if an object is not null
meta
| def | func:isNonNull |
| is | func |
| lib | lib:axon |
| name | isNonNull |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isNull
isNull(val)
Return if an object is null
meta
| def | func:isNull |
| is | func |
| lib | lib:axon |
| name | isNull |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isNumber
isNumber(val)
Return if an object is a number type
meta
| def | func:isNumber |
| is | func |
| lib | lib:axon |
| name | isNumber |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isOdd
isOdd(val)
Return if an integer is an odd number.
meta
| def | func:isOdd |
| is | func |
| lib | lib:axon |
| name | isOdd |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isRef
isRef(val)
Return if an object is a ref type
meta
| def | func:isRef |
| is | func |
| lib | lib:axon |
| name | isRef |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isSpace
isSpace(num)
Is number is whitespace char: space \t \n \r \f
Examples:
isSpace("x".get(0)) >> false
isSpace(" ".get(0)) >> true
isSpace("\n".get(0)) >> truemeta
| def | func:isSpace |
| is | func |
| lib | lib:axon |
| name | isSpace |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isSpan
isSpan(val)
Return if an object is a span
meta
| def | func:isSpan |
| is | func |
| lib | lib:axon |
| name | isSpan |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isStr
isStr(val)
Return if an object is a str type
meta
| def | func:isStr |
| is | func |
| lib | lib:axon |
| name | isStr |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isTagName
isTagName(n)
Return if the given string is legal tag name - see Etc.isTagName
meta
| def | func:isTagName |
| is | func |
| lib | lib:axon |
| name | isTagName |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isTime
isTime(val)
Return if an object is a Time type
meta
| def | func:isTime |
| is | func |
| lib | lib:axon |
| name | isTime |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isUpper
isUpper(num)
Is number an ASCII uppercase alphabetic char: A-Z
Examples:
isUpper("A".get(0)) >> true
isUpper("a".get(0)) >> false
isUpper("5".get(0)) >> falsemeta
| def | func:isUpper |
| is | func |
| lib | lib:axon |
| name | isUpper |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isUri
isUri(val)
Return if an object is a Uri type
meta
| def | func:isUri |
| is | func |
| lib | lib:axon |
| name | isUri |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isWeekday
isWeekday(t)
Does the given Date or DateTime fall on Mon, Tue, Wed, Thu, or Fri
meta
| def | func:isWeekday |
| is | func |
| lib | lib:axon |
| name | isWeekday |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:isWeekend
isWeekend(t)
Does the given Date or DateTime fall on Sat or Sun
meta
| def | func:isWeekend |
| is | func |
| lib | lib:axon |
| name | isWeekend |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:join
join(a, b, joinColName)
Join two grids by column name. Current implementation requires:
- grids cannot have conflicting col names (other than join col)
- each row in both grids must have a unique value for join col
- grid level meta is merged
- join column meta is merged
meta
| def | func:join |
| is | func |
| lib | lib:axon |
| name | join |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:joinAll
joinAll(grids, joinColName)
Join a list of grids into a single grid. See join().
meta
| def | func:joinAll |
| is | func |
| lib | lib:axon |
| name | joinAll |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:keepCols
keepCols(grid, cols)
Return a new grid with keeps the given columns, but removes all the others. Columns can be Str names or Col instances. Also see Streams.
Example:
readAll(site).keepCols(["id", "area"])meta
| def | func:keepCols |
| is | func |
| lib | lib:axon |
| name | keepCols |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:last
last(val)
Get the last item from an ordered collection or return null if the collection is empty:
- list: item at index -1
- grid: item at index -1
- stream: last item; see Streams
meta
| def | func:last |
| is | func |
| lib | lib:axon |
| name | last |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:lastMonth
lastMonth()
DateSpan for month previous to this month 1..28-31
meta
| def | func:lastMonth |
| is | func |
| lib | lib:axon |
| name | lastMonth |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:lastOfMonth
lastOfMonth(date)
Get the last day of the date's month. Also see firstOfMonth().
Example:
2009-10-28.lastOfMonth >> 2009-10-31meta
| def | func:lastOfMonth |
| is | func |
| lib | lib:axon |
| name | lastOfMonth |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:lastQuarter
lastQuarter()
DateSpan for 3 month quarter previous to this quarter
meta
| def | func:lastQuarter |
| is | func |
| lib | lib:axon |
| name | lastQuarter |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:lastWeek
lastWeek()
DateSpan for week previous to this week sun..sat (uses locale start of week)
meta
| def | func:lastWeek |
| is | func |
| lib | lib:axon |
| name | lastWeek |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:lastYear
lastYear()
DateSpan for year previous to this year Jan-1..Dec-31
meta
| def | func:lastYear |
| is | func |
| lib | lib:axon |
| name | lastYear |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:libs
libs()
List the lib definitions in the context namespace as Def[].
meta
| def | func:libs |
| is | func |
| lib | lib:axon |
| name | libs |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:limit
limit(stream, limit)
Truncate stream after given limit is reached. See Streams.
meta
| def | func:limit |
| is | func |
| lib | lib:axon |
| name | limit |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:localeUse
localeUse(locale, expr)
Evaluate an expression within a specific locale. This enables formatting and parsing of localized text using a locale other than the default for the current context.
Examples:
// format Date in German
localeUse("de", today().format)
// parse Date in German
localeUse("de", parseDate("01 Mär 2021", "DD MMM YYYY"))meta
| def | func:localeUse |
| is | func |
| lib | lib:axon |
| name | localeUse |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:lower
lower(val)
Convert a char number or str to ASCII lower case. Also see upper() and decapitalize().
Examples:
lower("CAT") >> "cat"
lower("Cat") >> "cat"
lower(65).toChar >> "a"meta
| def | func:lower |
| is | func |
| lib | lib:axon |
| name | lower |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:map
map(val, fn)
Map list, dict, or grid by applying the given mapping function.
If mapping a list, the mapping should be a function that takes (val) or (val, index). It should return the new value for that index.
If mapping a dict, the mapping should be a function that takes (val) or (val, name). It should return the new value for that name.
If mapping a grid, the mapping function takes (row) or (row,index) and returns a new dictionary to use for the row. The resulting grid shares the original's grid level meta. Columns left intact share the old meta-data, new columns have no meta-data. If the mapping function returns null, then that row is removed from the resulting grid (not mapped).
If mapping a range, then the mapping function takes (integer), and returns a list for each mapped integer inte the range.
If mapping a stream, the mapping functions takes (val). See Streams.
Examples:
// create list adding ten to each number
[1, 2, 3].map(v => v+10) >> [11, 12, 13]
// create new list that turns strings into uppercase
["ape", "bee", "cat"].map(upper) // ["APE, "BEE", "CAT"]
// create dict adding ten to each value
{a:1, b:2, c:3}.map(v => v+10) >> {a:11, b:12, c:13}
// create grid with just dis, area column
readAll(site).map(s => {dis:s->dis, area:s->area})meta
| def | func:map |
| is | func |
| lib | lib:axon |
| name | map |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:marker
marker()
Get the marker value singleton Marker.val
meta
| def | func:marker |
| is | func |
| lib | lib:axon |
| name | marker |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:max
max(val, acc)
Compare two numbers and return the larger one. This function may also be used with fold() to return the largest number (or null if no values). Note number units are not checked nor considered for the comparison.
Examples:
max(7, 4) >> 7
[7, 2, 4].fold(max) >> 7meta
| def | func:max |
| disKey | ui::max |
| foldOn | Number |
| is | func |
| lib | lib:axon |
| name | max |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:merge
merge(a, b)
Merge two Dicts together and return a new Dict. Any tags in b are added to a. If b defines a tag already in a, then it is overwritten by b. If a tag in b is mapped to Remove.val, then that tag is removed from the result.
meta
| def | func:merge |
| is | func |
| lib | lib:axon |
| name | merge |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:meta
meta(val)
Get the meta-data from a grid or col as a dict.
Examples:
read(temp).hisRead(today).meta // grid meta
read(temp).hisRead(today).col("ts").meta // column metameta
| def | func:meta |
| is | func |
| lib | lib:axon |
| name | meta |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:min
min(val, acc)
Compare two numbers and return the smaller one. This function may also be used with fold() to return the smallest number (or null if no values). Note number units are not checked nor considered for this comparison.
Examples:
min(7, 4) >> 4
[7, 2, 4].fold(min) >> 2meta
| def | func:min |
| disKey | ui::min |
| foldOn | Number |
| is | func |
| lib | lib:axon |
| name | min |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:minute
minute(t)
Get minutes of the time as integer between 0 to 59 from time or datetime
meta
| def | func:minute |
| is | func |
| lib | lib:axon |
| name | minute |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:missing
missing(val, name)
If val is a Grid return if it does not have given column name. If val is a Dict, return if the given name is not mapped to a non-null value.
meta
| def | func:missing |
| is | func |
| lib | lib:axon |
| name | missing |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:month
month(d)
Get month as integer between 1 to 12 from date or datetime
meta
| def | func:month |
| is | func |
| lib | lib:axon |
| name | month |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:moveTo
moveTo(list, item, toIndex)
Find the given item in a list, and move it to the given index. All the other items are shifted accordingly. Negative indexes may used to access an index from the end of the list. If the item is not found then this is a no op. Return new list.
Examples:
[10, 11, 12].moveTo(11, 0) >> [11, 10, 12]
[10, 11, 12].moveTo(11, -1) >> [10, 12, 11]meta
| def | func:moveTo |
| is | func |
| lib | lib:axon |
| name | moveTo |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:na
na()
Get NA not-available singleton NA.val
meta
| def | func:na |
| is | func |
| lib | lib:axon |
| name | na |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:name
name(val)
If val is a Col, get the column name.
Example:
// get name of first column
readAll(site).cols.first.namemeta
| def | func:name |
| is | func |
| lib | lib:axon |
| name | name |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:names
names(dict)
Get the list of names used by a given dict
meta
| def | func:names |
| is | func |
| lib | lib:axon |
| name | names |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:nan
nan()
Return the Number representation of not-a-number
meta
| def | func:nan |
| is | func |
| lib | lib:axon |
| name | nan |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:negInf
negInf()
Return the Number representation negative infinity
meta
| def | func:negInf |
| is | func |
| lib | lib:axon |
| name | negInf |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:now
now()
Return current DateTime according to context's time zone. This function will use a cached version which is only accurate to within 250ms (see DateTime.now for details). Also see nowTicks() and nowUtc().
meta
| def | func:now |
| is | func |
| lib | lib:axon |
| name | now |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:nowTicks
nowTicks()
Return current time as nanosecond ticks since 1 Jan 2000 UTC. Note that the 64-bit floating point representations of nanosecond ticks will lose accuracy below the microsecond. Also see now().
meta
| def | func:nowTicks |
| is | func |
| lib | lib:axon |
| name | nowTicks |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:nowUtc
nowUtc()
Return current DateTime in UTC. This function will use a cached version which is only accurate to within 250ms (see DateTime.nowUtc for details). Also see now() and nowTicks().
meta
| def | func:nowUtc |
| is | func |
| lib | lib:axon |
| name | nowUtc |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:numDays
numDays(span)
Number of whole days in a span
meta
| def | func:numDays |
| is | func |
| lib | lib:axon |
| name | numDays |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:numDaysInMonth
numDaysInMonth(month: null)
Get the number of days in a given month. The month parameter may be:
- Date: returns number of days in given month (uses month/year, ignores day)
- Number 1-12: returns days in month for current year
- null: returns day in current month
Examples:
numDaysInMonth() >>> days in current month
numDaysInMonth(1) >>> 31day (days in January)
numDaysInMonth(6) >>> 30day (days in June)
numDaysInMonth(2) >>> 28day or 29day (days for Feb this year)
numDaysInMonth(2012-02-13) >>> 29day (days in Feb for leap year)meta
| def | func:numDaysInMonth |
| is | func |
| lib | lib:axon |
| name | numDaysInMonth |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:occurred
occurred(ts, range)
Return if a timestamp is contained within a Date range. Range may be any value supported by toDateSpan(). Timestamp may be either a Date or a DateTime. Also see contains.
Examples:
ts.occurred(thisWeek)
ts.occurred(pastMonth())
ts.occurred(2010-01-01..2010-01-15)meta
| def | func:occurred |
| is | func |
| lib | lib:axon |
| name | occurred |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:padl
padl(val, width, char: " ")
Pad string to the left. If size is less than width, then add the given char to the left to achieve the specified width.
Examples:
"3".padl(3, "0") >> "003"
"123".padl(2, "0") >> "123"meta
| def | func:padl |
| is | func |
| lib | lib:axon |
| name | padl |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:padr
padr(val, width, char: " ")
Pad string to the right. If size is less than width, then add the given char to the left to acheive the specified with.
Examples:
"xyz".padr(2, ".") >> "xyz"
"xyz".padr(5, "-") >> "xyz--"meta
| def | func:padr |
| is | func |
| lib | lib:axon |
| name | padr |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseAst
parseAst(src)
Parse Axon source code into an abstract syntax tree modeled as a tree of dicts. Each node has a type tag which specified the node type. Common AST shapes:
123 => {type:"literal", val:123}
a => {type:"var", name:"a"}
not a => {type:"not", operand:{type:"var", name:"a"}}
a + b => {type:"add", lhs:{type:"var", name:"a"}, rhs:{type:"var", name:"b"}}NOTE: the keys and structure of the AST is subject to change over time.
meta
| def | func:parseAst |
| is | func |
| lib | lib:axon |
| name | parseAst |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseBool
parseBool(val, checked: true)
Parse a Str into a Bool, legal formats are "true" or "false. If invalid format and checked is false return null, otherwise throw ParseErr.
Examples:
parseBool("true")
parseBool("bad", false)meta
| def | func:parseBool |
| is | func |
| lib | lib:axon |
| name | parseBool |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseDate
parseDate(val, pattern: "YYYY-MM-DD", checked: true)
Parse a Str into a Date. If the string cannot be parsed into a valid Date and checked is false then return null, otherwise throw ParseErr. See Date.toLocale for pattern.
Examples:
parseDate("7-Feb-23", "D-MMM-YY")
parseDate("07/02/23", "DD/MM/YY")
parseDate("7 february 2023", "D MMMM YYYY")
parseDate("230207", "YYMMDD")meta
| def | func:parseDate |
| is | func |
| lib | lib:axon |
| name | parseDate |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseDateTime
parseDateTime(val, pattern: "YYYY-MM-DD'T'hh:mm:SS.FFFFFFFFFz zzzz", tz: now().tz, checked: true)
Parse a Str into a DateTime. If the string cannot be parsed into a valid DateTime and checked is false then return null, otherwise throw ParseErr. See DateTime.toLocale for pattern:
YY Two digit year 07
YYYY Four digit year 2007
M One/two digit month 6, 11
MM Two digit month 06, 11
MMM Three letter abbr month Jun, Nov
MMMM Full month June, November
D One/two digit day 5, 28
DD Two digit day 05, 28
DDD Day with suffix 1st, 2nd, 3rd, 24th
WWW Three letter abbr weekday Tue
WWWW Full weekday Tuesday
V One/two digit week of year 1,52
VV Two digit week of year 01,52
VVV Week of year with suffix 1st,52nd
h One digit 24 hour (0-23) 3, 22
hh Two digit 24 hour (0-23) 03, 22
k One digit 12 hour (1-12) 3, 11
kk Two digit 12 hour (1-12) 03, 11
m One digit minutes (0-59) 4, 45
mm Two digit minutes (0-59) 04, 45
s One digit seconds (0-59) 4, 45
ss Two digit seconds (0-59) 04, 45
SS Optional seconds (only if non-zero)
f* Fractional secs trailing zeros
F* Fractional secs no trailing zeros
a Lower case a/p for am/pm a, p
aa Lower case am/pm am, pm
A Upper case A/P for am/pm A, P
AA Upper case AM/PM AM, PM
z Time zone offset Z, +03:00 (ISO 8601, XML Schema)
zzz Time zone abbr EST, EDT
zzzz Time zone name New_York
'xyz' Literal characters
'' Single quote literalExamples:
parseDateTime("2023-02-07 14:30", "YYYY-MM-DD hh:mm")
parseDateTime("2023-02-07 14:30", "YYYY-MM-DD hh:mm", "Paris")
parseDateTime("7/2/23 2:30pm", "D/M/YY k:mma")
parseDateTime("2023-02-07T14:30:00", "YYYY-MM-DD'T'hh:mm:ss")meta
| def | func:parseDateTime |
| is | func |
| lib | lib:axon |
| name | parseDateTime |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseFilter
parseFilter(val, checked: true)
Parse a filter string into a Filter instance. The resulting filter can then be used with read(), readAll(), filter(), or filterToFunc().
Example:
str: "point and kw"
readAll(parseFilter(str))meta
| def | func:parseFilter |
| is | func |
| lib | lib:axon |
| name | parseFilter |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseFloat
parseFloat(val, checked: true)
Parse a Str into a Float. Representations for infinity and not-a-number are "-INF", "INF", "NaN". If invalid format and checked is false return null, otherwise throw ParseErr. This string value cannot include a unit (see parseNumber).
Examples:
parseFloat("123.456").format("0.000")
parseFloat("NaN")
parseFloat("INF")meta
| def | func:parseFloat |
| is | func |
| lib | lib:axon |
| name | parseFloat |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseInt
parseInt(val, radix: 10, checked: true)
Parse a Str into a integer number using the specified radix. If invalid format and checked is false return null, otherwise throw ParseErr. This string value cannot include a unit (see parseNumber).
Examples:
parseInt("123")
parseInt("afe8", 16)
parseInt("10010", 2)meta
| def | func:parseInt |
| is | func |
| lib | lib:axon |
| name | parseInt |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseNumber
parseNumber(val, checked: true)
Parse a Str into a number with an option unit. If invalid format and checked is false return null, otherwise throw ParseErr. Also see parseInt() and parseFloat() to parse basic integers and floating point numbers without a unit.
Examples:
parseNumber("123")
parseNumber("123kW")
parseNumber("123.567").format("#.000")meta
| def | func:parseNumber |
| is | func |
| lib | lib:axon |
| name | parseNumber |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseRef
parseRef(val, dis: null, checked: true)
Parse a Str into a Ref. If the string is not a valid Ref identifier then raise ParseErr or return null based on checked flag. If the string has a leading "@", then it is stripped off before parsing.
Examples:
parseRef("abc-123")
parseRef("@abc-123")meta
| def | func:parseRef |
| is | func |
| lib | lib:axon |
| name | parseRef |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseSearch
parseSearch(val)
Parse a search string into a Filter instance. The resulting filter can then be used with read(), readAll(), filter(), or filterToFunc().
The search string is one of the following free patterns:
*<glob>*case insensitive glob with ? and * wildcards (default)re:<regex>regular expressionf:<filter>haystack filter
See Nav for additional details on search syntax.
Examples:
readAll(parseSearch("RTU-1"))
readAll(point).filter(parseSearch("RTU* Fan"))meta
| def | func:parseSearch |
| is | func |
| lib | lib:axon |
| name | parseSearch |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseSymbol
parseSymbol(val, checked: true)
Parse a Str into a Symbol. If the string is not a valid Symbol identifier then raise ParseErr or return null based on checked flag. The string must not include a leading "^".
Examples:
parseSymbol("func:now")meta
| def | func:parseSymbol |
| is | func |
| lib | lib:axon |
| name | parseSymbol |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseTime
parseTime(val, pattern: "hh:mm:SS", checked: true)
Parse a Str into a Time. If the string cannot be parsed into a valid Time and checked is false then return null, otherwise throw ParseErr. See Time.toLocale for pattern.
Examples:
parseTime("14:30", "h:mm")
parseTime("2:30pm", "k:mma")
parseTime("2:30:00pm", "k:mm:ssa")meta
| def | func:parseTime |
| is | func |
| lib | lib:axon |
| name | parseTime |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseUnit
parseUnit(val, checked: true)
Parse a Str into a standardized unit name. If the val is not a valid unit name from the standard database then return null or raise exception based on checked flag.
Examples:
parseUnit("%")
parseUnit("percent")meta
| def | func:parseUnit |
| is | func |
| lib | lib:axon |
| name | parseUnit |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:parseUri
parseUri(val, checked: true)
Parse a string into a Uri instance. If the string cannot be parsed into a valid Uri and checked is false then return null, otherwise throw ParseErr. This function converts an URI from standard form. Use uriDecode() to convert a string from escaped form. See Uri for a detailed discussion on standard and escaped forms.
Examples:
"foo bar".parseUri >> `foo bar`
"foo%20bar".uriDecode >> `foo bar`meta
| def | func:parseUri |
| is | func |
| lib | lib:axon |
| name | parseUri |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:pastMonth
pastMonth()
DateSpan for last 30days today-30days..today
meta
| def | func:pastMonth |
| is | func |
| lib | lib:axon |
| name | pastMonth |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:pastWeek
pastWeek()
DateSpan for last 7 days as today-7days..today
meta
| def | func:pastWeek |
| is | func |
| lib | lib:axon |
| name | pastWeek |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:pastYear
pastYear()
DateSpan for this past today-365days..today
meta
| def | func:pastYear |
| is | func |
| lib | lib:axon |
| name | pastYear |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:posInf
posInf()
Return the Number representation positive infinity
meta
| def | func:posInf |
| is | func |
| lib | lib:axon |
| name | posInf |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:reFind
reFind(regex, s)
Find the first match of regular expression in s or return null if no matches. See AxonUsage.
Examples:
reFind(r"\d+", "x123y") >> "123"
reFind(r"\d+", "xyz") >> nullmeta
| def | func:reFind |
| is | func |
| lib | lib:axon |
| name | reFind |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:reFindAll
reFindAll(regex, s)
Find all matches of the regular expression in s. Returns an empty list of there are no matches.
Examples:
reFindAll(r"-?\d+\.?\d*", "foo, 123, bar, 456.78, -9, baz")
>> ["123", "456.78", "-9"]
reFindAll(r"\d+", "foo, bar, baz")
>> [,]meta
| def | func:reFindAll |
| is | func |
| lib | lib:axon |
| name | reFindAll |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:reGroups
reGroups(regex, s)
Return a list of the substrings captured by matching the given regular operation against s. Return null if no matches. The first item in the list is the entire match, and each additional item is matched to () arguments in the regex pattern. See AxonUsage.
Examples:
re: r"(RTU|AHU)-(\d+)"
reGroups(re, "AHU") >> null
reGroups(re, "AHU-7") >> ["AHU-7", "AHU", "7"]meta
| def | func:reGroups |
| is | func |
| lib | lib:axon |
| name | reGroups |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:reMatches
reMatches(regex, s)
Return if regular expression matches entire region of s. See AxonUsage.
Examples:
reMatches(r"\d+", "x123y") >> false
reMatches(r"\d+", "123") >> truemeta
| def | func:reMatches |
| is | func |
| lib | lib:axon |
| name | reMatches |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:reduce
reduce(val, init, fn)
Reduce a collection to a single value with the given reducer function. The given function is called with each item in the collection along with a current accumulation value. The accumation value is initialized to init for the first item, and for every subsequent item it is the result of the previous item. Return the final accumulation value. Also see fold() which is preferred if doing standard rollup such as sum or average.
If working with a list, the function takes (acc, val, index) and returns accumulation value
If working with a grid, the function takes (acc, row, index) and returns accumulation value
If working with a stream, then function takes (acc, val) and returns accumulation value See Streams.
Examples:
[2, 5, 3].reduce(0, (acc, val)=>acc+val) >> 10
[2, 5, 3].reduce(1, (acc, val)=>acc*val) >> 30meta
| def | func:reduce |
| is | func |
| lib | lib:axon |
| name | reduce |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:refDis
refDis(ref)
Given a ref return Ref.dis
meta
| def | func:refDis |
| is | func |
| lib | lib:axon |
| name | refDis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:refGen
refGen()
Generate a new unique Ref identifier
meta
| def | func:refGen |
| is | func |
| lib | lib:axon |
| name | refGen |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:refProjName
refProjName(ref, checked: true)
Given an absolute ref, return its project name. If the ref is not formatted as "p:proj:r:xxx", then raise an exception or return null based on the checked flag:
Examples:
refProjName(@p:demo:r:xxx) >> "demo"
refProjName(@r:xxx) >> raises exception
refProjName(@r:xxx, false) >> nullmeta
| def | func:refProjName |
| is | func |
| lib | lib:axon |
| name | refProjName |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:relDis
relDis(parent, child)
Get a relative display name. If the child display name starts with the parent, then we can strip that as the common suffix. Parent and child must be either a Dict or a Str.
meta
| def | func:relDis |
| is | func |
| lib | lib:axon |
| name | relDis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:remove
remove(val, key)
Remove an item from a collection and return a new collection.
- List: key is index to remove at
- Dict: key is tag name
meta
| def | func:remove |
| is | func |
| lib | lib:axon |
| name | remove |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:removeCol
removeCol(grid, col)
Return a new grid with the given column removed. If the column doesn't exist, then return given grid. Also see Streams.
meta
| def | func:removeCol |
| is | func |
| lib | lib:axon |
| name | removeCol |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:removeCols
removeCols(grid, cols)
Return a new grid with all the given columns removed. Columns can be Str names or Col instances. Also see Streams.
meta
| def | func:removeCols |
| is | func |
| lib | lib:axon |
| name | removeCols |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:removeMarker
removeMarker()
Get the remove value singleton Remove.val
meta
| def | func:removeMarker |
| is | func |
| lib | lib:axon |
| name | removeMarker |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:renameCol
renameCol(grid, oldName, newName)
Return a new grid with the given column renamed.
Example:
readAll(site).renameCol("dis", "title")meta
| def | func:renameCol |
| is | func |
| lib | lib:axon |
| name | renameCol |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:renameCols
renameCols(grid, mapping)
Return a new grid with multiple columns renamed. Mapping must be a dict of old to new names. Old column names not found are ignored.
Example:
readAll(site).renameCols({dis:"title", geoAddr:"subtitle"})meta
| def | func:renameCols |
| is | func |
| lib | lib:axon |
| name | renameCols |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:reorderCols
reorderCols(grid, colNames)
Return a new grid with the columns reordered. The given list of names represents the new order and must contain the same current column names. Any columns not specified are removed. Also see colNames(), moveTo(), and Streams.
Example:
// move name to first col, and foo to last col
cols: grid.colNames.moveTo("name", 0).moveTo("foo", -1)
return grid.reorderCols(cols)meta
| def | func:reorderCols |
| is | func |
| lib | lib:axon |
| name | reorderCols |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:replace
replace(val, from, to)
String replace of all occurrences of from with to. All three parameters must be strings.
Examples:
"hello".replace("hell", "t") >> "to"
"aababa".replace("ab", "-") >> "a--a"meta
| def | func:replace |
| is | func |
| lib | lib:axon |
| name | replace |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:rowToList
rowToList(row)
Get a grid row as a list of cells. Sparse cells are included as null. Also see colToList().
Example:
readAll(equip).first.rowToListmeta
| def | func:rowToList |
| is | func |
| lib | lib:axon |
| name | rowToList |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:second
second(t)
Get seconds of the time as integer between 0 to 59 from time or datetime
meta
| def | func:second |
| is | func |
| lib | lib:axon |
| name | second |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:set
set(val, key, item)
Set a collection item and return a new collection.
- List: set item by index key
- Dict: set item by key name
meta
| def | func:set |
| is | func |
| lib | lib:axon |
| name | set |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:setColMeta
setColMeta(grid, name, meta)
Return a new grid with column meta-data replaced by given meta dict. If column not found, then return given grid. Also see addColMeta() and Streams.
meta
| def | func:setColMeta |
| is | func |
| lib | lib:axon |
| name | setColMeta |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:setMeta
setMeta(grid, meta)
Return new grid with grid level meta-data replaced by given meta Dict. Also see addMeta() and Streams.
Example:
read(temp).hisRead(today).setMeta({view:"table"})meta
| def | func:setMeta |
| is | func |
| lib | lib:axon |
| name | setMeta |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:size
size(val)
Return number of items in str, list, or grid
meta
| def | func:size |
| is | func |
| lib | lib:axon |
| name | size |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:skip
skip(stream, count)
Skip the given number of items in a stream. See Streams.
meta
| def | func:skip |
| is | func |
| lib | lib:axon |
| name | skip |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:sort
sort(val, sorter: null)
Sort a list or grid.
If sorting a list, the sorter should be a function that takes two list items and returns -1, 0, or 1 (typicaly done with the <=> operator. If no sorter is passed, then the list is sorted by its natural ordering.
If sorting a grid, the sorter can be a column name or a function. If a function, it should take two rows and return -1, 0, or 1.
Examples:
// sort string list
["bear", "cat", "apple"].sort
// sort string list by string size
["bear", "cat", "apple"].sort((a,b) => a.size <=> b.size)
// sort sites by area
readAll(site).sort((a, b) => a->area <=> b->area)meta
| def | func:sort |
| is | func |
| lib | lib:axon |
| name | sort |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:sortDis
sortDis(val)
Sort a grid by row display name - see Grid.sortDis
Examples:
// read all sites and sort by display name
readAll(site).sortDismeta
| def | func:sortDis |
| is | func |
| lib | lib:axon |
| name | sortDis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:sortr
sortr(val, sorter: null)
Reverse sort a list or grid. This function works just like sort() except sorts in reverse.
meta
| def | func:sortr |
| is | func |
| lib | lib:axon |
| name | sortr |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:split
split(val, sep: null, opts: null)
Split a string by the given separator and trim whitespace. If sep is null then split by any whitespace char; otherwise it must be exactly one char long. See Str.split for detailed behavior.
Options:
- noTrim: disable auto-trim of whitespace from start and end of tokens
Examples:
"a b c".split >> ["a", "b", "c"]
"a,b,c".split(",") >> ["a", "b", "c"]
"a, b, c".split(",") >> ["a", "b", "c"]
"a, b, c".split(",", {noTrim}) >> ["a", " b", " c"]meta
| def | func:split |
| is | func |
| lib | lib:axon |
| name | split |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:spread
spread(val, acc)
Fold multiple values to compute the difference between the max and min value. Return null if no values.
Example:
[7, 2, 3].fold(spread) >> 5meta
| def | func:spread |
| disKey | ui::spread |
| foldOn | Number |
| is | func |
| lib | lib:axon |
| name | spread |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:start
start(val)
Start value of a DateSpan, Span or a range.
meta
| def | func:start |
| is | func |
| lib | lib:axon |
| name | start |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:startOfWeek
startOfWeek()
Return current locale's start of weekday. Weekday is returned as integer from 0 (Sunday) to 6 (Saturday).
meta
| def | func:startOfWeek |
| is | func |
| lib | lib:axon |
| name | startOfWeek |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:startsWith
startsWith(val, sub)
Return if Str starts with the specified Str.
Examples:
"hi there".startsWith("hi") >> true
"hi there".startsWith("foo") >> falsemeta
| def | func:startsWith |
| is | func |
| lib | lib:axon |
| name | startsWith |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:stream
stream(val)
Create new stream from given collection:
- Grid: stream the rows
- List: stream the items
- Range: stream inclusive range of integers See Streams.
meta
| def | func:stream |
| is | func |
| lib | lib:axon |
| name | stream |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:streamCol
streamCol(grid, col)
Create a new stream for the cell values of the given column. See Streams.
meta
| def | func:streamCol |
| is | func |
| lib | lib:axon |
| name | streamCol |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:sum
sum(val, acc)
Fold multiple values into their numeric sum. Return null if no values.
meta
| def | func:sum |
| disKey | ui::sum |
| foldOn | Number |
| is | func |
| lib | lib:axon |
| name | sum |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:swizzleRefs
swizzleRefs(grid)
Given a grid of records, assign new ids and swizzle all internal ref tags. Each row of the grid must have an id tag. A new id is generated for each row, and any Ref tags which used one of the old ids is replaced with the new id. This function is handy for copying graphs of recs such as site/equip/point trees.
meta
| def | func:swizzleRefs |
| is | func |
| lib | lib:axon |
| name | swizzleRefs |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tags
tags()
List tag definitions in the context namespace as Def[].
meta
| def | func:tags |
| is | func |
| lib | lib:axon |
| name | tags |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:terms
terms()
List term definitions (tags and conjuncts) in the context namespace as Def[].
meta
| def | func:terms |
| is | func |
| lib | lib:axon |
| name | terms |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:thisMonth
thisMonth()
DateSpan for this month as 1st..28-31
meta
| def | func:thisMonth |
| is | func |
| lib | lib:axon |
| name | thisMonth |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:thisQuarter
thisQuarter()
DateSpan for this 3 month quarter
meta
| def | func:thisQuarter |
| is | func |
| lib | lib:axon |
| name | thisQuarter |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:thisWeek
thisWeek()
DateSpan for this week as sun..sat (uses locale start of week)
meta
| def | func:thisWeek |
| is | func |
| lib | lib:axon |
| name | thisWeek |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:thisYear
thisYear()
DateSpan for this year Jan-1..Dec-31
meta
| def | func:thisYear |
| is | func |
| lib | lib:axon |
| name | thisYear |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:time
time(val, minutes: null, secs: 0)
If val is a DateTime: get time portion of the timestamp. If val is a Number: construct a time instance from hour, minutes, secs (truncated to nearest second).
Examples:
now().time // current time
time(20, 45) // same as 20:45meta
| def | func:time |
| is | func |
| lib | lib:axon |
| name | time |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:times
times(times, fn)
Call the specified function the given number of times passing the counter.
meta
| def | func:times |
| is | func |
| lib | lib:axon |
| name | times |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:to
to(val, unit)
Convert a number to the given unit. If the units are not of the same dimension then an exception is raised. The target unit can be a string or a Number. If target unit is a Number, then the scalar value is ignored, but by convention should be 1. Also see as() function to set a unit without conversion.
Examples:
10kWh.to(1BTU)
10kWh.to("BTU")
75°F.to(1°C)
to(75°F, 1°C)meta
| def | func:to |
| is | func |
| lib | lib:axon |
| name | to |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toAxonCode
toAxonCode(val)
Convert a scalar, list, or dict value to its Axon code representation. Examples:
toAxonCode(123) => "123"
toAxonCode([1, 2, 3]) => "[1, 2, 3]"
toAxonCode({x:123}) => "{x:123}"meta
| def | func:toAxonCode |
| is | func |
| lib | lib:axon |
| name | toAxonCode |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toChar
toChar(num)
Convert a unicode char number into a single char string
Examples:
toChar(65) >> "A"meta
| def | func:toChar |
| is | func |
| lib | lib:axon |
| name | toChar |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toDateSpan
toDateSpan(x)
Convert the following objects into a DateSpan:
Func: function which evaluates to date rangeDateSpan: return itselfDate: one day rangeSpan: returnSpan.toDateSpanStr: evaluates toDateSpan.fromStrDate..Date: starting and ending date (inclusive)Date..Number: starting date and num of days (day unit required)DateTime..DateTime: use starting/ending dates; if end is midnight, then use previous dateNumber: convert as year- null: use projMeta dateSpanDefault or default to today (deprecated)
Examples:
toDateSpan(2010-07-01..2010-07-03) >> 01-Jul-2010..03-Jul-2010
toDateSpan(2010-07-01..60day) >> 01-Jul-2010..29-Aug-2010
toDateSpan(2010-07) >> 01-Jul-2010..31-Jul-2010
toDateSpan(2010) >> 01-Jan-2010..31-Dec-2010
toDateSpan(pastWeek) // on 9 Aug >> 02-Aug-2010..09-Aug-2010meta
| def | func:toDateSpan |
| is | func |
| lib | lib:axon |
| name | toDateSpan |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toGrid
toGrid(val, meta: null)
Given an arbitrary object, translate it to a Grid via Etc.toGrid:
- if grid just return it
- if row in grid of size, return row.grid
- if scalar return 1x1 grid
- if dict return grid where dict is only
- if list of dict return grid where each dict is row
- if list of non-dicts, return one col grid with rows for each item
Example:
// create simple grid with dis,age cols and 3 rows:
[{dis:"Bob", age:30},
{dis:"Ann", age:40},
{dis:"Dan", age:50}].toGridmeta
| def | func:toGrid |
| is | func |
| lib | lib:axon |
| name | toGrid |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toHex
toHex(val)
Convert a number to a hexadecimal string.
meta
| def | func:toHex |
| is | func |
| lib | lib:axon |
| name | toHex |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toJavaMillis
toJavaMillis(dt)
Given a DateTime return Number of milliseconds since Unix epoch. The epic is defined as 1-Jan-1970 UTC. Also see fromJavaMillis().
meta
| def | func:toJavaMillis |
| is | func |
| lib | lib:axon |
| name | toJavaMillis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toList
toList(val)
If val is a list return it, otherwise return [val].
meta
| def | func:toList |
| is | func |
| lib | lib:axon |
| name | toList |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toLocale
toLocale(key)
Get the localized string for the given tag name or qualified name. If the key is formatted as "pod::name" then route to Env.locale, otherwise to Etc.tagToLocale.
meta
| def | func:toLocale |
| is | func |
| lib | lib:axon |
| name | toLocale |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toRadix
toRadix(val, radix, width: null)
Convert a number to its string representation in the given radix (base). If width is non-null, then leading zeroes are prepended to ensure the specified width.
Example:
6.toRadix(2) => "110"
255.toRadix(16, 4) => "00ff"meta
| def | func:toRadix |
| is | func |
| lib | lib:axon |
| name | toRadix |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toSpan
toSpan(x, tz: null)
Convert the following objects into a Span:
Span: return itselfSpan+tz: update timezone using same dates only if aligned to midnightStr: returnSpan.fromStrusing current timezoneStr+tz: returnSpan.fromStrusing given timezoneDateTime..DateTime: range of two DateTimesDate..DateTime: start day for date until the end timestampDateTime..Date: start timestamp to end of day for end dateDateTime: span of a single timestampDateSpan: anything accepted bytoDateSpan()in current timezoneDateSpan+tz: anything accepted bytoDateSpan()using given timezone
meta
| def | func:toSpan |
| is | func |
| lib | lib:axon |
| name | toSpan |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toStr
toStr(val)
Convert an obj to its string representation
meta
| def | func:toStr |
| is | func |
| lib | lib:axon |
| name | toStr |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toTagName
toTagName(n)
Given arbitrary string, convert to a safe tag name - see Etc.toTagName
meta
| def | func:toTagName |
| is | func |
| lib | lib:axon |
| name | toTagName |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:toTimeZone
toTimeZone(val, tz)
Convert a DateTime or Span to another timezone:
now().toTimeZone("Chicago")
now().toTimeZone("UTC")meta
| def | func:toTimeZone |
| is | func |
| lib | lib:axon |
| name | toTimeZone |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:today
today()
Return today's Date according to context's time zone
meta
| def | func:today |
| is | func |
| lib | lib:axon |
| name | today |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:transpose
transpose(grid)
Perform a matrix transpose on the grid. The cells of the first column because the display names for the new columns. Columns 1..n become the new rows.
Example:
readAll(site).transposemeta
| def | func:transpose |
| is | func |
| lib | lib:axon |
| name | transpose |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:trap
trap(val, name)
Function for the -> operator. If the given value is a dict, then get a value by name, or throw UnknownNameErr if name not mapped. If the value is a Ref, then perform a checked readById, then perform the name lookup.
The trap function maybe be accessed using the -> shortcut operator:
dict->foo >>> dict.trap("foo")See Axon Language.
meta
| def | func:trap |
| is | func |
| lib | lib:axon |
| name | trap |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:trim
trim(val)
Trim whitespace from the beginning and end of the string. For the purposes of this function, whitespace is defined as any character equal to or less than the 0x20 space character (including , \r, \n, and \t).
Examples:
" abc ".trim >> "abc"
"abc".trim >> "abc"meta
| def | func:trim |
| is | func |
| lib | lib:axon |
| name | trim |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:trimEnd
trimEnd(val)
Trim whitespace only from the end of the string. See trim() for definition of whitespace.
Examples:
" abc ".trimEnd >> " abc"
"abc".trimEnd >> "abc"meta
| def | func:trimEnd |
| is | func |
| lib | lib:axon |
| name | trimEnd |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:trimStart
trimStart(val)
Trim whitespace only from the beginning of the string. See trim() for definition of whitespace.
Examples:
" abc ".trimStart >> "abc "
"abc".trimStart >> "abc"meta
| def | func:trimStart |
| is | func |
| lib | lib:axon |
| name | trimStart |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tz
tz(dt: null)
Get timezone as city name string in tzinfo database from datetime. If the datetime is null then return the environment default timezone.
meta
| def | func:tz |
| is | func |
| lib | lib:axon |
| name | tz |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:unique
unique(val, key: null)
Return the unique items in a collection. If val is a List then return List.unique. If val is a Grid then return Grid.unique where key must be a column name or list of column names.
Examples:
[1, 1, 2, 2].unique >> [1, 2]
grid.unique("geoState") >> unique states
grid.unique(["geoCity", geoState"]) >> city,state combosmeta
| def | func:unique |
| is | func |
| lib | lib:axon |
| name | unique |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:unit
unit(val)
Given a number return its unit string or null. If the val is null, then return null.
meta
| def | func:unit |
| is | func |
| lib | lib:axon |
| name | unit |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:unitsEq
unitsEq(a, b)
Return if the two numbers have the same unit. If either of the numbers if null return false.
meta
| def | func:unitsEq |
| is | func |
| lib | lib:axon |
| name | unitsEq |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:upper
upper(val)
Convert a char number or str to ASCII upper case. Also see lower() and capitalize().
Examples:
upper("cat") >> "CAT"
upper("Cat") >> "CAT"
upper(97).toChar >> "A"meta
| def | func:upper |
| is | func |
| lib | lib:axon |
| name | upper |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:uriBasename
uriBasename(val)
Get the basename (last name in path without extension) of a Uri as a string.
meta
| def | func:uriBasename |
| is | func |
| lib | lib:axon |
| name | uriBasename |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |