Math.Multiply
This shard multiplies the input value by the value provided in the Operand parameter.
Details
Multiplication is a binary operation, i.e., it needs two arguments to give a result.
The Math.Multiply
shard takes in the Input and the parameter :Operand
to produce the Output .
Both Input and :Operand
can be an integer, a float, or a sequence of such entities (but both value types should match for a given operation). The Output is generally of the same type as the Input provided to the shard.
See also
Binary operations on sequences
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 ; Multiply integers
5 | Log ; prints input => 5
| Math.Multiply(2) | Log ; prints input * operand => 10
| Assert.Is(10 Break: true) ; expect: (5 * 2) => 10
; Multiply floats
5.3 | Log ; prints input => 5.3
| Math.Multiply(2.1) | Log ; prints input * operand => 11.13
| Assert.Is(11.13 Break: true) ; expect: (5.3 * 2.1) => 11.13
; Multiply equal-sized sequences
[4 5.1 6.4] | Log ; prints input => [4 5.1 6.4]
| Math.Multiply([3 4.0 2.2]) ; input seq elements compute with corresponding operand seq elements
| Log ; prints input * operand => [12 20.4 14.08]
| Assert.IsAlmost([12 20.4 14.08] Break: true) ; expect: [(4 * 3) (5.1 * 4.0) (6.4 * 2.2)] => [12 20.4 14.08]
; Multiply unequal-sized sequences (input size < operand size)
[4.0] | Log ; prints input => [4.0]
| Math.Multiply([3.0 4.0 2.2]) ; input seq elements compute with corresponding operand seq elements
| Log ; prints input * operand => [12.0]
| Assert.Is([12.0] Break: true) ; expect: [(4.0 * 3.0) ... ...] => [12.0]
; Multiply unequal-sized sequences (input size > operand size)
[4 2 1 5 8] | Log ; prints input => [4 2 1 5 8]
| Math.Multiply([6 4]) ; input seq elements compute with corresponding operand seq elements
| Log ; prints input * operand => [24 8 6 20 48]
| Assert.Is([24 8 6 20 48] Break: true) ; expect: [(4 * 6) (2 * 4) (1 * 6) (5 * 4) (8 * 6)] => [24 8 6 20 48]
[info] [sample-wire] 5
[info] [sample-wire] 10
[info] [sample-wire] 5.3
[info] [sample-wire] 11.13
[info] [sample-wire] [4 5.1 6.4]
[info] [sample-wire] [12 20.4 14.08]
[info] [sample-wire] [4]
[info] [sample-wire] [12]
[info] [sample-wire] [4 2 1 5 8]
[info] [sample-wire] [24 8 6 20 48]
; Multiply floats
5.3 | Log ; prints input => 5.3
| Math.Multiply(2.1) | Log ; prints input * operand => 11.13
| Assert.Is(11.13 Break: true) ; expect: (5.3 * 2.1) => 11.13
[info] [sample-wire] 5.3
[info] [sample-wire] 11.13
; Multiply equal-sized sequences
[4 5.1 6.4] | Log ; prints input => [4 5.1 6.4]
| Math.Multiply([3 4.0 2.2]) ; input seq elements compute with corresponding operand seq elements
| Log ; prints input * operand => [12 20.4 14.08]
| Assert.IsAlmost([12 20.4 14.08] Break: true) ; expect: [(4 * 3) (5.1 * 4.0) (6.4 * 2.2)] => [12 20.4 14.08]
[info] [sample-wire] [4 5.1 6.4]
[info] [sample-wire] [12 20.4 14.08]
; Multiply unequal-sized sequences (input size < operand size)
[4.0] | Log ; prints input => [4.0]
| Math.Multiply([3.0 4.0 2.2]) ; input seq elements compute with corresponding operand seq elements
| Log ; prints input * operand => [12.0]
| Assert.Is([12.0] Break: true) ; expect: [(4.0 * 3.0) ... ...] => [12.0]
[info] [sample-wire] [4]
[info] [sample-wire] [12]
; Multiply unequal-sized sequences (input size > operand size)
[4 2 1 5 8] | Log ; prints input => [4 2 1 5 8]
| Math.Multiply([6 4]) ; input seq elements compute with corresponding operand seq elements
| Log ; prints input * operand => [24 8 6 20 48]
| Assert.Is([24 8 6 20 48] Break: true) ; expect: [(4 * 6) (2 * 4) (1 * 6) (5 * 4) (8 * 6)] => [24 8 6 20 48]
[info] [sample-wire] [4 2 1 5 8]
[info] [sample-wire] [24 8 6 20 48]