Skip to content
Permalink
Browse files

Update map and array examples

  • Loading branch information
m-kuhn committed Aug 24, 2018
1 parent 7e63093 commit ec4483a51a28763141b16c5fa7a3219de9972ef5
@@ -7,6 +7,6 @@
{"arg":"value1", "syntaxOnly": true},
{"arg":"value2", "syntaxOnly": true},
{"arg":"value", "descOnly": true, "description":"a value"}],
"examples": [ { "expression":"array(2,10)", "returns":"array: 2, 10"}
"examples": [ { "expression":"array(2,10)", "returns":"[ 2, 10 ]"}
]
}
@@ -4,5 +4,5 @@
"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"}]
"examples": [ { "expression":"array_append(array(1,2,3),4)", "returns":"[ 1, 2, 3, 4 ]"}]
}
@@ -7,6 +7,6 @@
{"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"}
"examples": [ { "expression":"array_cat(array(1,2),array(2,3))", "returns":"[ 1, 2, 2, 3 ]"}
]
}
@@ -4,6 +4,6 @@
"description": "Returns an array containing distinct values of the given array.",
"arguments": [
{"arg":"array","description":"an array"}],
"examples": [ { "expression":"array_distinct(array(1,2,3,2,1))", "returns":"array: 1,2,3"}
"examples": [ { "expression":"array_distinct(array(1,2,3,2,1))", "returns":"[ 1, 2, 3 ]"}
]
}
@@ -7,7 +7,7 @@
{"arg":"expression","description":"an expression to evaluate on each item. The variable `@element` will be replaced by the current value."}
],
"examples": [
{ "expression": "array_foreach(array('a','b','c'),upper(@element))", "returns":"array: 'A', 'B', 'C'"},
{ "expression": "array_foreach(array(1,2,3),@element + 10)", "returns":"array: 11, 12, 13"}
{ "expression": "array_foreach(array('a','b','c'),upper(@element))", "returns":"[ 'A', 'B', 'C' ]"},
{ "expression": "array_foreach(array(1,2,3),@element + 10)", "returns":"[ 11, 12, 13 ]"}
]
}
@@ -5,5 +5,5 @@
"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"}]
"examples": [ { "expression":"array_insert(array(1,2,3),1,100)", "returns":"[ 1, 100, 2, 3 ]"}]
}
@@ -4,5 +4,5 @@
"description": "Returns an array with the given value added at the beginning.",
"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"}]
"examples": [ { "expression":"array_prepend(array(1,2,3),0)", "returns":"[ 0, 1, 2, 3 ]"}]
}
@@ -4,5 +4,5 @@
"description": "Returns an array with all the entries of the given value removed.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"value","description":"the values to remove"}],
"examples": [ { "expression":"array_remove_all(array('a','b','c','b'),'b')", "returns":"array: 'a','c'"}]
"examples": [ { "expression":"array_remove_all(array('a','b','c','b'),'b')", "returns":"[ 'a', 'c' ]"}]
}
@@ -4,5 +4,5 @@
"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"}]
"examples": [ { "expression":"array_remove_at(array(1,2,3),1)", "returns":"[ 1, 3 ]"}]
}
@@ -3,5 +3,5 @@
"type": "function",
"description": "Returns the given array with array values in reversed order.",
"arguments": [ {"arg":"array","description":"an array"} ],
"examples": [ { "expression":"array_reverse(array(2,4,0,10))", "returns":"array: 10,0,4,2"}]
"examples": [ { "expression":"array_reverse(array(2,4,0,10))", "returns":"[ 10, 0, 4, 2 ]"}]
}
@@ -17,35 +17,35 @@
],
"examples": [{
"expression": "array_slice(array(1,2,3,4,5),0,3)",
"returns": "array: 1,2,3,4"
"returns": "[ 1, 2, 3, 4 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),0,-1)",
"returns": "array: 1,2,3,4,5"
"returns": "[ 1, 2, 3, 4, 5 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),-5,-1)",
"returns": "array: 1,2,3,4,5"
"returns": "[ 1, 2, 3, 4, 5 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),0,0)",
"returns": "array: 1"
"returns": "[ 1 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),-2,-1)",
"returns": "array: 4,5"
"returns": "[ 4, 5 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),-1,-1)",
"returns": "array: 5"
"returns": "[ 5 ]"
},
{
"expression": "array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),1,2)",
"returns": "array: 'Valmiera','Chugiak'"
"returns": "[ 'Valmiera', 'Chugiak' ]"
},
{
"expression": "array_slice(array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),-2,-1)",
"returns": "array: 'Chugiak','Brighton'"
"returns": "[ 'Chugiak', 'Brighton' ]"
}
]
}
@@ -7,7 +7,7 @@
{"arg":"stop", "description":"value that ends the sequence once reached"},
{"arg":"step","optional":true,"default":"1","description":"value used as the increment between values"}
],
"examples": [ { "expression":"generate_series('1,5)", "returns":"array: '1', '2', '3', '4', '5'"},
{ "expression":"generate_series('5,1,-1)", "returns":"array: '5', '4', '3', '2', '1'"}
"examples": [ { "expression":"generate_series('1,5)", "returns":"[ 1, 2, 3, 4, 5 ]"},
{ "expression":"generate_series('5,1,-1)", "returns":"[ 5, 4, 3, 2, 1 ]"}
]
}
@@ -10,6 +10,6 @@
{"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'"}
"examples": [ { "expression":"map('1','one','2', 'two')", "returns":"{ '1': 'one', '2': 'two' }"}
]
}
@@ -3,5 +3,5 @@
"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'"}]
"examples": [ { "expression":"map_akeys(map('1','one','2','two'))", "returns":"[ '1', '2' ]"}]
}
@@ -3,5 +3,5 @@
"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'"}]
"examples": [ { "expression":"map_avals(map('1','one','2','two'))", "returns":"[ 'one', 'two' ]"}]
}
@@ -7,6 +7,6 @@
{"arg":"map1", "syntaxOnly": true},
{"arg":"map2", "syntaxOnly": true},
{"arg":"map", "descOnly": true, "description":"a map"}],
"examples": [ { "expression":"map_concat(map('1','one', '2','overridden'),map('2','two', '3','three'))", "returns":"map: 1: 'one, 2: 'two', 3: 'three'"}
"examples": [ { "expression":"map_concat(map('1','one', '2','overridden'),map('2','two', '3','three'))", "returns":"{ '1': 'one, '2': 'two', '3': 'three' }"}
]
}
@@ -4,5 +4,5 @@
"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'"}]
"examples": [ { "expression":"map_delete(map('1','one','2','two'),'2')", "returns":"{ '1': 'one' }"}]
}
@@ -5,5 +5,5 @@
"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'"}]
"examples": [ { "expression":"map_insert(map('1','one'),'3','three')", "returns":"{ '1': 'one', '3': 'three' }"}]
}
@@ -6,7 +6,7 @@
{"arg":"string", "description":"the string to capture groups from against the regular expression"},
{"arg":"regex","description":"the regular expression used to capture groups"},
{"arg":"empty_value","optional":true,"default":"''","description":"the optional string to use as replacement for empty (zero length) matches"}],
"examples": [ { "expression":"regexp_matches('QGIS=>rocks','(.*)=>(.*)')", "returns":"array: 'QGIS', 'rocks'"},
{ "expression":"regexp_matches('key=>','(.*)=>(.*)','empty value')", "returns":"array: 'key', 'empty value'"}
"examples": [ { "expression":"regexp_matches('QGIS=>rocks','(.*)=>(.*)')", "returns":"[ 'QGIS', 'rocks' ]"},
{ "expression":"regexp_matches('key=>','(.*)=>(.*)','empty value')", "returns":"[ 'key', 'empty value' ]"}
]
}
@@ -6,7 +6,7 @@
{"arg":"string", "description":"the input string"},
{"arg":"delimiter","optional":true,"default":"','","description":"the string delimiter used to split the input string"},
{"arg":"empty_value","optional":true,"default":"''","description":"the optional string to use as replacement for empty (zero length) matches"}],
"examples": [ { "expression":"string_to_array('1,2,3',',')", "returns":"array: '1', '2', '3'"},
{ "expression":"string_to_array('1,,3',',','0')", "returns":"array: '1', '0', '3'"}
"examples": [ { "expression":"string_to_array('1,2,3',',')", "returns":"[ '1', '2', '3' ]"},
{ "expression":"string_to_array('1,,3',',','0')", "returns":"[ '1', '0', '3' ]"}
]
}

0 comments on commit ec4483a

Please sign in to comment.
You can’t perform that action at this time.