First class environments: Difference between revisions

→‎{{header|jq}}: space vs time
(mv jq to its proper place alphabetically)
(→‎{{header|jq}}: space vs time)
Line 694:
 
 
Finally, to present the results in tabular form, twothe following helper functionsfunction will be useful:
 
# Emit the last item in a stream
# or null if the stream is empty
def last(s): reduce s as $s (null; $s);
 
# Apply a filter to a stream,
# and ALSO emit the last item in the stream filtered through "final"
def filter_and_last(s; filter; final):
([s] |as filter), (last(s) | final);$array
| ($array[] | filter), ($array[-1] | final);
 
 
2,442

edits