-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3500 from pvalsecc/array_exprs
Add expression functions for arrays and maps
- Loading branch information
Showing
24 changed files
with
564 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "array", | ||
"type": "function", | ||
"description": "Returns an array containing all the values passed as parameter.", | ||
"variableLenArguments": true, | ||
"arguments": [ | ||
{"arg":"value1", "syntaxOnly": true}, | ||
{"arg":"value2", "syntaxOnly": true}, | ||
{"arg":"value", "descOnly": true, "description":"a value"}], | ||
"examples": [ { "expression":"array(2,10)", "returns":"array: 2, 10"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "array_append", | ||
"type": "function", | ||
"description": "Returns an array with the given value added at the end.", | ||
"arguments": [ {"arg":"array","description":"an array"}, | ||
{"arg":"value","description":"the value to add"}], | ||
"examples": [ { "expression":"array_append(array(1,2,3),4)", "returns":"array: 1,2,3,4"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "array_cat", | ||
"type": "function", | ||
"description": "Returns an array containing all the given arrays concatenated.", | ||
"variableLenArguments": true, | ||
"arguments": [ | ||
{"arg":"array1", "syntaxOnly": true}, | ||
{"arg":"array2", "syntaxOnly": true}, | ||
{"arg":"array", "descOnly": true, "description":"an array"}], | ||
"examples": [ { "expression":"array_cat(array(1,2),array(2,3))", "returns":"array: 1,2,2,3"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "array_contains", | ||
"type": "function", | ||
"description": "Returns true if an array contains the given value.", | ||
"arguments": [ {"arg":"array","description":"an array"}, | ||
{"arg":"value","description":"the value to search"}], | ||
"examples": [ { "expression":"array_contains(array(1,2,3),2)", "returns":"true"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "array_find", | ||
"type": "function", | ||
"description": "Returns the index (0 for the first one) of a value within an array. Returns -1 if the value is not found.", | ||
"arguments": [ {"arg":"array","description":"an array"}, | ||
{"arg":"value","description":"the value to search"}], | ||
"examples": [ { "expression":"array_find(array(1,2,3),2)", "returns":"1"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "array_get", | ||
"type": "function", | ||
"description": "Returns the Nth value (0 for the first one) of an array.", | ||
"arguments": [ {"arg":"array","description":"an array"}, | ||
{"arg":"index","description":"the index to get (0 based)"}], | ||
"examples": [ { "expression":"array_get(array('a','b','c'),1)", "returns":"'b'"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "array_insert", | ||
"type": "function", | ||
"description": "Returns an array with the given value added at the given position.", | ||
"arguments": [ {"arg":"array","description":"an array"}, | ||
{"arg":"pos","description":"the position where to add (0 based"}, | ||
{"arg":"value","description":"the value to add"}], | ||
"examples": [ { "expression":"array_insert(array(1,2,3),1,100)", "returns":"array: 1,100,2,3"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "array_intersect", | ||
"type": "function", | ||
"description": "Returns true if any element of array1 exists in array2.", | ||
"arguments": [ {"arg":"array1","description":"an array"}, | ||
{"arg":"array2","description":"an other array"}], | ||
"examples": [ { "expression":"array_intersect(array(1,2,3,4),array(4,0,2,5))", "returns":"true"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "array_length", | ||
"type": "function", | ||
"description": "Returns the number of elements of an array.", | ||
"arguments": [ {"arg":"array","description":"an array"}], | ||
"examples": [ { "expression":"array_length(array(1,2,3))", "returns":"3"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "array_prepend", | ||
"type": "function", | ||
"description": "Returns an array with the given value added at the begining.", | ||
"arguments": [ {"arg":"array","description":"an array"}, | ||
{"arg":"value","description":"the value to add"}], | ||
"examples": [ { "expression":"array_prepend(array(1,2,3),0)", "returns":"array: 0,1,2,3"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "array_remove_all", | ||
"type": "function", | ||
"description": "Returns an array with all the entries of the given value removed.", | ||
"arguments": [ {"arg":"array","description":"an array"}, | ||
{"arg":"value","description":"the value to add"}], | ||
"examples": [ { "expression":"array_remove_all(array('a','b','c','b'),'b')", "returns":"array: 'a','c'"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "array_remove_at", | ||
"type": "function", | ||
"description": "Returns an array with the given index removed.", | ||
"arguments": [ {"arg":"array","description":"an array"}, | ||
{"arg":"pos","description":"the position to remove (0 based"}], | ||
"examples": [ { "expression":"array_remove_at(array(1,2,3),1)", "returns":"array: 1,3"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "map", | ||
"type": "function", | ||
"description": "Returns a map containing all the keys and values passed as pair of parameters.", | ||
"variableLenArguments": true, | ||
"arguments": [ | ||
{"arg":"key1", "syntaxOnly": true}, | ||
{"arg":"value1", "syntaxOnly": true}, | ||
{"arg":"key2", "syntaxOnly": true}, | ||
{"arg":"value2", "syntaxOnly": true}, | ||
{"arg":"key", "descOnly": true, "description":"a key (string)"}, | ||
{"arg":"value", "descOnly": true, "description":"a value"}], | ||
"examples": [ { "expression":"map('1','one','2', 'two')", "returns":"map: 1: 'one', 2: 'two'"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "map_akeys", | ||
"type": "function", | ||
"description": "Returns all the keys of a map as an array.", | ||
"arguments": [ {"arg":"map","description":"a map"}], | ||
"examples": [ { "expression":"map_akeys(map('1','one','2','two'))", "returns":"array: '1', '2'"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "map_avals", | ||
"type": "function", | ||
"description": "Returns all the values of a map as an array.", | ||
"arguments": [ {"arg":"map","description":"a map"}], | ||
"examples": [ { "expression":"map_avals(map('1','one','2','two'))", "returns":"array: 'one', 'two'"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "map_concat", | ||
"type": "function", | ||
"description": "Returns a map containing all the entries of the given map. If two maps contain the same key, the value of the second map is taken.", | ||
"variableLenArguments": true, | ||
"arguments": [ | ||
{"arg":"map1", "syntaxOnly": true}, | ||
{"arg":"map2", "syntaxOnly": true}, | ||
{"arg":"map", "descOnly": true, "description":"a map"}], | ||
"examples": [ { "expression":"map_concat(map('1','one', '2','overriden'),map('2','two', '3','three'))", "returns":"map: 1: 'one, 2: 'two', 3: 'three'"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "map_delete", | ||
"type": "function", | ||
"description": "Returns a map with the given key and its corresponding value deleted.", | ||
"arguments": [ {"arg":"map","description":"a map"}, | ||
{"arg":"key","description":"the key to delete"}], | ||
"examples": [ { "expression":"map_delete(map('1','one','2','two'),'2')", "returns":"map: 1: 'one'"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "map_exist", | ||
"type": "function", | ||
"description": "Returns true if the given key exists in the map.", | ||
"arguments": [ {"arg":"map","description":"a map"}, | ||
{"arg":"key","description":"the key to lookup"}], | ||
"examples": [ { "expression":"map_exist(map('1','one','2','two'),'3')", "returns":"false"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "map_get", | ||
"type": "function", | ||
"description": "Returns the value of a map, given it's key.", | ||
"arguments": [ {"arg":"map","description":"a map"}, | ||
{"arg":"key","description":"the key to lookup"}], | ||
"examples": [ { "expression":"map_get(map('1','one','2','two'),'2')", "returns":"'two'"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "map_insert", | ||
"type": "function", | ||
"description": "Returns a map with an added key/value.", | ||
"arguments": [ {"arg":"map","description":"a map"}, | ||
{"arg":"key","description":"the key to add"}, | ||
{"arg":"value","description":"the value to add"}], | ||
"examples": [ { "expression":"map_insert(map('1','one'),'3','three')", "returns":"map: 1: 'one', 3: 'three'"}] | ||
} |
Oops, something went wrong.