ZCubes/Z Programming and Combinatorial Arguments

Z Programming and Combinatorial Arguments


This video demonstrates how to enable functions to be able to process arrays of values, instead of single value arguments. Using the ‘arrayfy’ feature, the function that handles a set of parameters can handle a range of values for each parameter. This powerful feature of handling 'combinatorial arguments' opens up the possibility of evaluating functions for wide range of values without any changes to the function code.

Video


Z Programming and Combinatorial Arguments














Examples

Finding velocity : Final velocity (v) of an object equals initial velocity (u) of that object plus acceleration (a) of the object times the elapsed time (t) from u to v. For standard gravity, a = 9.80665 m/s2.

1. To find the final velocity (V), use the ZCubes code as-
v := u+a*t;
v(1,9.8,1)

displays the result as 10.8.


2. To find the final velocity(V) for array of values of 't' from 1 to 30, use the following ZCubes code as-
V := u+a*t;
V arr; //typing arr and pressing Shift+Space key gives an character '#'
V(1,9.8,1..30)

displays the final velocity values with varying inputs of time as:

u      t       V

9.8 1 10.8
9.8 2 20.6
9.8 3 30.400000000000002
9.8 4 40.2
9.8 5 50
9.8 6 59.800000000000004
9.8 7 69.60000000000001
9.8 8 79.4
9.8 9 89.2
9.8 10 99
9.8 11 108.80000000000001
9.8 12 118.60000000000001
9.8 13 128.4
9.8 14 138.20000000000002
9.8 15 148
9.8 16 157.8
9.8 17 167.60000000000002
9.8 18 177.4
9.8 19 187.20000000000002
9.8 20 197
9.8 21 206.8
9.8 22 216.60000000000002
9.8 23 226.4
9.8 24 236.20000000000002
9.8 25 246.00000000000003
9.8 26 255.8
9.8 27 265.6
9.8 28 275.40000000000003
9.8 29 285.20000000000005
9.8 30 295


3. To find the final velocity(V) for array of values of 't' and 'u' from 1 to 30, use the following ZCubes code as-
V := u+a*t;
V arr; //typing arr and pressing Shift+Space key gives an character '#'
V(1..30,9.8,1..30)






© Copyright 1996-2021, ZCubes, Inc.