Utility methods for collections.
Flattenize a collection.
Transform any input into collection. If already a collection return it.
Transform any collection into a collection of entries ie. object with key and value like OB Entries.
Key is index, and value is the value at this index.
Use Formula with collection functions like map, reduce, etc..
| Method Name | Formula Parameters | Result | Examples |
|---|---|---|---|
c_formula |
$1, $2, $3, ... | $0 ie. direct formula result | test_c_formula |
c_formula_this |
This.value, $1, $2, ... | $0 ie. direct formula result | test_c_formula_this |
c_formula_raw |
This.value, $1, $2, ... | This.result or This.accumulator must be modifyed | test_c_formula_raw |
$col:=New collection:C1472(1;2;3;4)
$result:=$col.map("c_formula";Formula:C1597($1+1)) // ++| Code | Description | Examples |
|---|---|---|
| bifurcate | Splits values into two groups using boolean bitmap | test_bifurcate |
| bifurcateBy | Splits values into two groups according to a predicate formula | test_bifurcateBy |
| countBy | Groups the elements based on the given formula and returns the count by group | test_countBy |
| groupBy | Groups the elements based on the given formula | test_groupBy |
| indexBy | Like groupBy, but for when you know your keys are unique. | test_indexBy |
| mostFrequent | Returns the most frequent element | test_mostFrequent |
| zipObject | Associate collections of keys and values and return an object | test_zipObject |
On Unix system open a terminal in your database root folder.
Download the latest release and put it into the Components/ folder
On unix system you could do it using this command
mkdir -p Components && curl -L https://github.com/mesopelagique/CollectionUtils/releases/latest/download/CollectionUtils.4DZ --output Components/CollectionUtils.4dzgit submodule add https://github.com/mesopelagique/CollectionUtils.git Components/CollectionUtils.4dbasegit submodule add https://github.com/mesopelagique/CollectionUtils.git Components/CollectionUtilsOpen the project, for instance in unix system
open Components/CollectionUtils/Project/CollectionUtils.4DProjectCompile it to Components/ folder. A CollectionUtils.4dbase will be created with inside a CollectionUtils.4dz
Execute allTests, which execute all method prefixed by test_