3 ms·
No kidding! This part in particular jumped out at me: > To work around this statelessness, you can wrap a sequence of independent values into an array, iterat
by johnday 4y ago
No kidding!
This part in particular jumped out at me:
> To work around this statelessness, you can wrap a sequence of independent values into an array, iterate over the array, then wrap that result back up into another array so you can pass the entire sequence as a single value downstream to the “next filter”.
This is literally just describing a map. A technique so generally applicable and useful that it's made its way into every modern imperative/procedural programming language I can think of. The idea that this person fails to recognise such a common multiparadigmatic programming idiom doesn't fill me with confidence about the design of zq.
- aarchi 4y agoIn fact, jq already has `map`, which would replace the article's pattern of `[.[]|add]` with `map(add)`. It is defined as such: def map(f): [.[] | f]; Many built-in functions in jq are implemented in jq, in terms of a small set of core primitives. The implementations can be inspected in builtin.jq. https://github.com/stedolan/jq/blob/master/src/builtin.jq#L3 https://github.com/stedolan/jq/blob/master/src/builtin.jq#L3