2.4.1Functions

add

Adds two items along the rules of VM '+' operator.

add( a, b )
a First operand
b Second operand
ReturnThe result of the sum.

This function operates also on strings, arrays and dictionaries replicating the behavior of the "+" operator as it is performed by the VM.

at

Passe-par-tout accessor function.

at( item, access, [value] )
item An array, string, or any accessible item or collection.
access A number, a range or a string to access the item.
value If given, will substitue the given item or range (new value).
Raise
AccessError in case the accessor is invalid for the given item type.

This function emulates all the language-level accessors provided by Falcon. Subscript accessors ([]) accepting numbers, ranges and generic items (for dictionaries) and property accessors (.) accepting strings are fully supported. When two parameters are passed, the function works in access semantics, while when the value parameter is also given, the function will work as an accessor/subscript assignment. In example, to change a string the at function can be used as a range accessor:


      string = "hello"
      string[0:1] = "H"          //first letter up
      at( string, [1:], "ELLO" ) // ...all up
      > string
      > "First letter: ", at( string, 0 )
                          // ^^^ same as string[0]

This function is also able to access and modify the bindings of arrays (i.e. like accessing the arrays using the "." operator), members of objects and instances and static methods of classes. Properties and bindings can be accessed by names as strings. In example:


      // making a binding
      // ... equivalent to "array.bind = ..."
      array = []
      at( array, "bind", "binding value" )
      > array.bind

      //... accessing a property
      at( CurrentTime(), "toRFC2822" )()

Trying to access an item with an incompatible type of accessor (i.e. trying to access an object with a range, or a string with a string).

Note: At the moment, the at function doesn't support BOM methods.

deq

Performs a deep equality check.

deq( a, b )
a First operand
b Second operand
Returntrue if the two items are deeply equal (same content).

div

Divides two numeric operands along the rules of VM '/' operator.

div( a, b )
a First operand
b Second operand
ReturnThe result of the division.

equal

Performs a lexicographic check for the first operand being equal to the second.

equal( a, b )
a First operand
b Second operand
Returntrue if a == b, false otherwise.

ge

Performs a lexicographic check for the first operand being greater or equal to the second.

ge( a, b )
a First operand
b Second operand
Returntrue if a >= b, false otherwise.

gt

Performs a lexicographic check for the first operand being greater than the second.

gt( a, b )
a First operand
b Second operand
Returntrue if a > b, false otherwise.

le

Performs a lexicographic check for the first operand being less or equal to the second.

le( a, b )
a First operand
b Second operand
Returntrue if a <= b, false otherwise.

lt

Performs a lexicographic check for the first operand being less than the second.

lt( a, b )
a First operand
b Second operand
Returntrue if a < b, false otherwise.

mod

Performs a modulo division on numeric operands along the rules of VM '%' operator.

mod( a, b )
a First operand
b Second operand
ReturnThe result of the modulo.

mul

Multiplies two items along the rules of VM '*' operator.

mul( a, b )
a First operand
b Second operand
ReturnThe result of the multiplication.

This function operates also on strings, arrays and dictionaries replicating the behavior of the "*" operator as it is performed by the VM.

neq

Performs a lexicographic check for the first operand being not equal to the second.

neq( a, b )
a First operand
b Second operand
Returntrue if a == b, false otherwise.

sub

Subtracts two items along the rules of VM '-' operator.

sub( a, b )
a First operand
b Second operand
ReturnThe result of the subtraction.

This function operates also on strings, arrays and dictionaries replicating the behavior of the "-" operator as it is performed by the VM.

Made with http://www.falconpl.org