both - Returns the list of keys and values of a context.
both(variable);
This function is used to return the list of keys and values of a context as a cotext. A context is an array in which instead of using numbers you use characters strings. Key contains the key name and, obviously, value contains the value. These are elements associated with the ones defined at the beginning(the keys).
If it is used as a function, it returns the list as an array.
If it is used as a callback, it returns each keys.
Note: In the following examples, the _ between the { should be removed to make it work.
res={_{ for i both({x:1,y:2}) do i; endfor; }}. return res={"key":"x","value":1}{"key":"y","value":2}. res={_{ for i both({x:[1,3],y:{a:2,b:"4"}}) do i; endfor; }}. return res={"key":"x","value":[1,3]}{"key":"y","value":{"a":2,"b":"4"}}. res={_{ a={x:1,y:2}; for i both(a) do i; endfor }}. return res={"key":"x","value":1}{"key":"y","value":2}. res={_{ a={}; for i both(a) do i; endfor }}. return res=. res={_{ for i both({}) do i; endfor }}. return res=. res={_{ for i both(123) do i; endfor }}. return .*is not a context.* res={_{ both({x:1,y:2}); }}. return res=[{"key":"x","value":1},{"key":"y","value":2}]. res={_{ a={x:1,y:2}; both(a); }}. return res=[{"key":"x","value":1},{"key":"y","value":2}]. res={_{ both({}); }}. return res=[]. res={_{ both(123); }}. return .*is not a context.* res={_{ a={x:[1,3],y:{a:2, b:4}}; both(a); }}. return res=[{"key":"x","value":[1,3]},{"key":"y","value":{"a":2,"b":4}}].
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
1.0 2014-09-09 21:24:14 laplante@sednove.com