First-class functions/Use numbers analogously: Difference between revisions

(→‎{{header|jq}}: transpose)
Line 815:
<syntaxhighlight lang="jq"># Infrastructure:
# zip this and that
def zip(that): [., that] | transpose;
. as $this | reduce range(0;length) as $i ([]; . + [ [$this[$i], that[$i]] ]);
 
# The task:
Line 833 ⟶ 832:
def multiplier(j): .[0] * .[1] * j;
 
numlist | zip(invlist) | map( multiplier(0.5) )</syntaxhighlight>
{{out}}
$ jq -n -c -f First_class_functions_Use_numbers_analogously.jq
[0.5,0.5,0.5]
 
As of this writing, there is no entry for jq at<!-- [[First-class functions#jq]]. -->
 
=={{header|JavaScript}}==
2,452

edits