On 20/08/2014 00:58, Peter Haworth wrote:
There's also the matrixMultiply command. It only works on numerically-keyed, single dimension arrays. Not sure why there isn't a matrixAdd/Subtract/Divide/etc but there's no mention of them in the dictionary.

But you get them (I think) just with "add", etc.

Dictionary says (with me trimming out the unnecessary parts)

add {number | array} to arrayContainer

Example:
add qty * price to last line of myOrder

Description:
Use the add command to add a number to a container or a portion of a container, or to add two arrays containing numbers.

Parameters:
The number is an expression that evaluates to a number.
The container is a field, button, or variable, or the message box.
The arrayContainer is an array variable each of whose elements is a number.

Comments:
If a number is added to an arrayContainer, the number is added to each element. If an array is added to an arrayContainer, both arrays must have the same number of elements and the same dimension, and each element in the array is added to the corresponding element of the arrayContainer.

If the container or an element of the arrayContainer is empty, the add command treats its contents as zero. If container is a field or button, the format of the sum is determined by the numberFormat property.



The dictionary also lists a transpose command but I honestly can;t figure out what use it is and since it causes a runtime error when I've tried to play with I haven't bothered to check it out.

Haven't used it, or even played with it - but the thing to note is that it was included since v1.1, when we didn't have true multi-dm arrays, so it expects pseudo- 2D array, where the keys are in the form [number,number], and every element must exist - i.e. you'd be hard pressed to find a useful use for it today.

We really should have a transpose (and come to think of it a matrixMultiply, etc.) command that work on modern 2-D arrays, i.e.
A[1][2], etc. rather than A[1,2]

-- Alex.

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to