INPUT /  OUTPUT /  LANGUAGE






add tag

Category: ephemeral logic tag

Obtains the result of adding multiple values together.

The add tag can sum all the values in a list, or sum a list of values against a single value, or sum two lists of values (such as two equal-sized vectors) pairwise against each other.

Sample usage

<add 1,1> produces 2.

<add 1 with=1> produces 2.

<add 1,10,-2 with=2> produces 3,12,0.

<add 2 with=1,10> produces 3,12.

<add 2,1 with=100,200> produces 102,201.

<add 2,1 with=1,10,20> produces invalid.

Fields

Primary field

Category: vector field

The tag's primary field takes a list of one or more values. When the (optional) with field is not used, the result produced by the tag is the sum of all values in the primary field.

Secondary fields

Behaviour

When the tag is complete, it produces out a value for one or more results of addition. The tag's lifetime then ends.

Depending on usage, the add tag can be used to perform simple addition (summing two or more values together), distributive addition (adding one value to a set of values), or vector addition (adding two sets of values).

The mode of operation depends on whether the with field is specified, and whether one value or multiple values are present in the primary and with fields.

The following describes this behaviour in detail. But simply refer to the sample usage examples above for examples.

Simple addition

If the with field is not used (simplest case), all values in the primary field are summed together from left to right.

Distributive addition

Vector addition

Example

The following code, when output to an ioL console, presents the user with a simple on-screen calculator.

<a:input 0> + <b:input 0> = <result:box 0></p>
<button {Evaluate} onClick=
    <result|add <num a>, <num b>>
>
The following non-interactive illustration shows what would be presented to the user in the console. When run in a real console, the user would be able to change the two initial values of 0 to any number and click the "Evaluate" button to add them together and see the result.

0
+
0
=
0

Evaluate