Arithmetic/Integer: Difference between revisions

Content added Content deleted
m (J: try to be not so awkward)
Line 852:
 
=={{header|J}}==
<lang j>calc =: + , - , * , <.@% , |~ , ^</lang>
The function <code>calc</code> constructs a list of numeric results for this task.
labels =: ];.2 'Sum: Difference: Product: Quotient: Remainder: Exponentiation: '
combine =: ,. ":@,.
bia =: labels combine calc</lang>
Note that the verb <tt>calc</tt> produces all the processing specified for this problem, and that its output is of numeric type.
<lang j> 17 calc 3
20 14 51 5 2 4913</lang>
 
The function <code>bia</code> assembles these results, textually:
Since other examples here provide textual output, <tt>bia</tt> produces like results.
 
<lang j>labels =: ];.2 'Sum: Difference: Product: Quotient: Remainder: Exponentiation: '
combine =: ,. ":@,.
bia =: labels combine calc</lang>
 
<lang j> 17 bia 3
Sum: 20
Difference: 14