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

→‎{{header|J}}: align with established pattern
(Use 'curry', compare to "First class functions")
(→‎{{header|J}}: align with established pattern)
Line 275:
 
=={{header|J}}==
{{incorrect|J|Compare and contrast the resultant program with the corresponding entry in First-class functions.}}
 
This seems to satisfy the new problem statement:
 
<lang j> x =: 2.0
xi =: 0.5
y =: 4.0
yi =: 0.25
z =: x + y
zi =: 1.0 % ( x + y ) NB. / is spelled % in J
 
A=: x,y,z
B=: %A
 
fwd =: x ,y ,z
multiplier=: conjunction def '(m*n)*]'
rev =: xi,yi,zi
 
BA multiplier =: A multiplier2 : 'm * n * B]'</lang>
 
Example use:
 
<lang> BAfwd 1multiplier rev 0.5
60.5 30.5 20.5</lang>
1 1 1
(A multiplier 1) 2
4 8 12
(3 multiplier B) 4
6 3 2</lang>
 
=={{header|Mathematica}}==
Anonymous user