First-class functions/Use numbers analogously: Difference between revisions
First-class functions/Use numbers analogously (view source)
Revision as of 06:43, 9 January 2023
, 1 year ago→{{header|jq}}: transpose
m (→{{header|Pascal}}: typo) |
(→{{header|jq}}: transpose) |
||
Line 815:
<syntaxhighlight lang="jq"># Infrastructure:
# zip this and that
def zip(that): [., that] | transpose;
# 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]
=={{header|JavaScript}}==
|