Difference between revisions of "Hash"
| (30 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
=== Hash # Operator === | === Hash # Operator === | ||
| − | + | Hash Operator (#) can have multiple meanings, when used as a binary operator or as suffix. It can be used to: (1) Arrafy Functions, (2) Index, Search and Filter Arrays, and (3) Index and Search Objects. Hash operator can be used to create lists of numbers, indices, etc., (similar to APL iota), but in far more powerful ways. | |
| − | + | ====# To Arrayfy Functions==== | |
| − | + | Any function can be enabled with Array handling for all (or some) parameters, by using # operator. For example: v:=u+a*t; creates a function v which computes the expression u+a*t, with u, a, and t as parameters. However, this function only takes simple parameters as inputs. To make the function v to be able to compute combinations of arrays as parameters, using [[ZCubes/Z_Programming_and_Combinatorial_Arguments | Combinatorial Arguments]], simply use the notation v# to enable array handling capabilities to each of the parameters. If we wish to exclude any parameter, provide an array of such parameters index as the suffix to #. For example, v#[1] will exclude "a" (the 1st index parameter) from handling input arrays. | |
| − | |||
| − | Any | ||
Once arrayfied, the function can take arrays as arguments, and for each of the cartesian product of the parameters, a result will be computed. For example, once arrayfied, v(1..2,3..4,1..10) will compute the value for v for each combination of the three parameter arrays. | Once arrayfied, the function can take arrays as arguments, and for each of the cartesian product of the parameters, a result will be computed. For example, once arrayfied, v(1..2,3..4,1..10) will compute the value for v for each combination of the three parameter arrays. | ||
| − | ==# | + | ====# To Split Strings==== |
# splits strings into arrays. | # splits strings into arrays. | ||
| Line 22: | Line 20: | ||
</pre> | </pre> | ||
| − | ==# | + | ====# To Index and Extract From Arrays==== |
| − | + | Hash Operator (#) can be used to index arrays, as below. If the right argument is an array, it will extract all elements represented by the indices on the right. If a multi-dimensional index is required, provide a subarray, such as [[2,3]] instead of [2,3]. To get the length of elements along a particular dimension, use the notation nd (For example, 1d to extract the size along the 1st dimension). | |
<pre> | <pre> | ||
| Line 53: | Line 51: | ||
(1..12)#/4/#TRUE | (1..12)#/4/#TRUE | ||
</pre> | </pre> | ||
| − | |||
| − | ==# | + | ====# To Access Object Members==== |
| − | # can be used to access members of | + | Hash Operator (#) can be used to access members of objects as below. |
<pre> | <pre> | ||
| Line 79: | Line 76: | ||
</pre> | </pre> | ||
| − | |||
<pre> | <pre> | ||
| + | |||
| + | a#["speed","weight"] // this extracts the fields as separate objects | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | { | ||
| + | "speed": 3 | ||
| + | } { | ||
| + | "weight": 34 | ||
| + | } | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | a#[["speed","weight"]] extracts the field values. | ||
| + | |||
| + | 3 34 | ||
| + | |||
| + | a#[[["details","size"]]] extracts the key subkey details/size. | ||
| + | |||
| + | large | ||
| + | |||
| + | ====# To Access Object Members from Array of Objects==== | ||
| + | |||
| + | Hash Operator (#) can be used to access members of objects in an array of objects as below. | ||
| + | |||
| + | |||
| + | <pre> | ||
| + | a= | ||
| + | [{ | ||
| + | "id": 1, | ||
| + | "first_name": "Jeanette", | ||
| + | "last_name": "Penddreth", | ||
| + | "email": "jpenddreth0@census.gov", | ||
| + | "gender": "Female", | ||
| + | "ip_address": "26.58.193.2" | ||
| + | }, { | ||
| + | "id": 2, | ||
| + | "first_name": "Giavani", | ||
| + | "last_name": "Frediani", | ||
| + | "email": "gfrediani1@senate.gov", | ||
| + | "gender": "Male", | ||
| + | "ip_address": "229.179.4.212" | ||
| + | }, { | ||
| + | "id": 3, | ||
| + | "first_name": "Noell", | ||
| + | "last_name": "Bea", | ||
| + | "email": "nbea2@imageshack.us", | ||
| + | "gender": "Female", | ||
| + | "ip_address": "180.66.162.255" | ||
| + | }, { | ||
| + | "id": 4, | ||
| + | "first_name": "Willard", | ||
| + | "last_name": "Valek", | ||
| + | "email": "wvalek3@vk.com", | ||
| + | "gender": "Male", | ||
| + | "ip_address": "67.76.188.26" | ||
| + | }] | ||
| + | a#"email" | ||
| + | a#"id,email,gender" | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</pre> | </pre> | ||
| + | |||
| + | |||
| + | {| style="" id="TABLE13" class="null wikitable" donotcaption="true" | | ||
| + | |- | ||
| + | | | ||
| + | {| style="" id="TABLE14" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | 1 | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | | | ||
| + | {| style="" id="TABLE15" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | style="cursor: row-resize;" | jpenddreth0@census.gov | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | | | ||
| + | {| style="" id="TABLE16" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | Female | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | |||
| + | |- | ||
| + | | | ||
| + | {| style="" id="TABLE17" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | 2 | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | | | ||
| + | {| style="" id="TABLE18" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | style="cursor: col-resize;" | gfrediani1@senate.gov | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | | style="cursor: auto;" | | ||
| + | {| style="" id="TABLE19" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | style="cursor: nwse-resize;" | Male | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | |||
| + | |- | ||
| + | | | ||
| + | {| style="" id="TABLE20" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | 3 | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | | | ||
| + | {| style="" id="TABLE21" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | nbea2@imageshack.us | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | | style="cursor: auto;" | | ||
| + | {| style="" id="TABLE22" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | style="cursor: col-resize;" | Female | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | |||
| + | |- | ||
| + | | | ||
| + | {| style="" id="TABLE23" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | 4 | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | | | ||
| + | {| style="" id="TABLE24" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | wvalek3@vk.com | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | | | ||
| + | {| style="" id="TABLE25" class="notepad" donotcaption="true" | | ||
| + | |- | ||
| + | | Male | ||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | |||
| + | |||
| + | |} | ||
| + | |||
| + | =====More Complex Keys and Queries to Arrays of Objects with #===== | ||
| + | |||
| + | Multiple keys can be comma separated, and subkeys can be separated with periods (.). Example: x#"id,email.official,address.zip" etc., where x is an array of objects with fields and subfields. | ||
| + | |||
| + | Simple numbers for indices will extract the specified objects at such indices. Example: a#1 extracts the element at index 1. a#1..3 gets elements at indices 1 to 3 etc. | ||
| + | |||
| + | These notations can be called from Calcis containing objects in cells etc. Example: =rs#"first_name,email where rs represents an array of objects. | ||
| + | |||
| + | ====Generating Arrays and Function Application==== | ||
| + | |||
| + | Hash operator can be powerful when applied to simple numbers. | ||
| + | |||
| + | List below show several ways a number can be arrayfied to give list comprehensions, iota, indices, generation of powerful arrays with function application and lists, etc. | ||
| + | |||
| + | For this behavior, the left side should be a number. The right side can be a number, string, array, function, etc. | ||
| + | |||
| + | The array on the right represents parameters such as start, interval, addition to each element, function to apply to each element etc. The added element can be complex numbers etc., giving extremely powerful list comprehensions with complex structures. | ||
| + | |||
| + | If the right side is a function, that function is applied over the generated series. | ||
| + | |||
| + | ====Generate array from number==== | ||
| + | 1) | ||
| + | <pre> | ||
| + | 3# // 0 indexed | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 012 | ||
| + | </pre> | ||
| + | ====Generate range starting at number==== | ||
| + | 1) | ||
| + | <pre> | ||
| + | 3#1 // 1..n | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 123 | ||
| + | </pre> | ||
| + | 2) | ||
| + | <pre> | ||
| + | 3#2 // start at 1 | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 23 | ||
| + | </pre> | ||
| + | |||
| + | ====Generate array from variable==== | ||
| + | 1) | ||
| + | <pre> | ||
| + | n=10; | ||
| + | n# | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0123456789 | ||
| + | </pre> | ||
| + | 2) | ||
| + | <pre> | ||
| + | n=10; | ||
| + | n#1 | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 12345678910 | ||
| + | </pre> | ||
| + | 4) | ||
| + | <pre> | ||
| + | 10#[-2,1] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | -2-1012345678910 | ||
| + | </pre> | ||
| + | 5) | ||
| + | <pre> | ||
| + | 10#[-2,2,100] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 98 100 102 104 106 108 110 | ||
| + | </pre> | ||
| + | 6) | ||
| + | <pre> | ||
| + | 10#[-2,2,2] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0 2 4 6 8 10 12 | ||
| + | </pre> | ||
| + | |||
| + | ====Custom steps with complex number==== | ||
| + | 1) | ||
| + | <pre> | ||
| + | n=10; | ||
| + | (n#[1,2.3,23i]) | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 1+23ⅈ 3.3+23ⅈ 5.6+23ⅈ 7.8999999999999995+23ⅈ | ||
| + | </pre> | ||
| + | 2) | ||
| + | <pre> | ||
| + | n=10; | ||
| + | n#[-3,2,34i] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | -3+34ⅈ -1+34ⅈ 1+34ⅈ 3+34ⅈ 5+34ⅈ 7+34ⅈ 9+34ⅈ | ||
| + | </pre> | ||
| + | 3) | ||
| + | <pre> | ||
| + | 30#[1,1,2.3] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 3.3 4.3 5.3 6.3 7.3 8.3 9.3 10.3 | ||
| + | </pre> | ||
| + | 4) | ||
| + | <pre> | ||
| + | n=10; | ||
| + | n#[-3,2,34i] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | -3+34ⅈ -1+34ⅈ 1+34ⅈ 3+34ⅈ 5+34ⅈ 7+34ⅈ 9+34ⅈ | ||
| + | </pre> | ||
| + | 5) | ||
| + | <pre> | ||
| + | 30#[0,1] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0 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 28 29 | ||
| + | </pre> | ||
| + | 6) | ||
| + | <pre> | ||
| + | 10#[0,1,SQUARED] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0 1 4 9 16 25 36 49 64 81 | ||
| + | </pre> | ||
| + | 7) | ||
| + | <pre> | ||
| + | 10#[1,1,SQUARED] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 1 4 9 16 25 36 49 64 81 100 | ||
| + | </pre> | ||
| + | 8) | ||
| + | <pre> | ||
| + | 10#[0,1,SQUARED] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0 1 4 9 16 25 36 49 64 81 | ||
| + | </pre> | ||
| + | ====Nested hash==== | ||
| + | 1) | ||
| + | <pre> | ||
| + | 10#[1,1,10#] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 1 2 3 4 5 6 7 8 9 10 | ||
| + | 2 3 4 5 6 7 8 9 10 11 | ||
| + | 3 4 5 6 7 8 9 10 11 12 | ||
| + | 4 5 6 7 8 9 10 11 12 13 | ||
| + | 5 6 7 8 9 10 11 12 13 14 | ||
| + | 6 7 8 9 10 11 12 13 14 15 | ||
| + | 7 8 9 10 11 12 13 14 15 16 | ||
| + | 8 9 10 11 12 13 14 15 16 17 | ||
| + | 9 10 11 12 13 14 15 16 17 18 | ||
| + | 10 11 12 13 14 15 16 17 18 19 | ||
| + | </pre> | ||
| + | 2) | ||
| + | <pre> | ||
| + | 10#[0,1,10#] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0 1 2 3 4 5 6 7 8 9 | ||
| + | 1 2 3 4 5 6 7 8 9 10 | ||
| + | 2 3 4 5 6 7 8 9 10 11 | ||
| + | 3 4 5 6 7 8 9 10 11 12 | ||
| + | 4 5 6 7 8 9 10 11 12 13 | ||
| + | 5 6 7 8 9 10 11 12 13 14 | ||
| + | 6 7 8 9 10 11 12 13 14 15 | ||
| + | 7 8 9 10 11 12 13 14 15 16 | ||
| + | 8 9 10 11 12 13 14 15 16 17 | ||
| + | 9 10 11 12 13 14 15 16 17 18 | ||
| + | </pre> | ||
| + | ====Apply SIN to series==== | ||
| + | 1) | ||
| + | <pre> | ||
| + | 10#[0,1,[SIN]] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0.8414709848078965 0.9092974268256817 0.1411200080598672 -0.7568024953079282 -0.9589242746631385 -0.27941549819892586 | ||
| + | 0.6569865987187891 0.9893582466233818 0.4121184852417566 -0.5440211108893698 | ||
| + | </pre> | ||
| + | 2) | ||
| + | <pre> | ||
| + | 10#[0,1,[SQUARED]] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 1 4 9 16 25 36 49 64 81 100 | ||
| + | </pre> | ||
| + | 3) | ||
| + | <pre> | ||
| + | 10#[0,1,[1,2,-1,-2,SQUARED]] | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 1 2 -1 -2 1 | ||
| + | 2 3 0 -1 4 | ||
| + | 3 4 1 0 9 | ||
| + | 4 5 2 1 16 | ||
| + | 5 6 3 2 25 | ||
| + | 6 7 4 3 36 | ||
| + | 7 8 5 4 49 | ||
| + | 8 9 6 5 64 | ||
| + | 9 10 7 6 81 | ||
| + | 10 11 8 7 100 | ||
| + | </pre> | ||
| + | ====Generate negative imaginary series==== | ||
| + | 1) | ||
| + | <pre> | ||
| + | 10#-1i | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0-1ⅈ 1-1ⅈ 2-1ⅈ 3-1ⅈ 4-1ⅈ 5-1ⅈ 6-1ⅈ 7-1ⅈ 8-1ⅈ 9-1ⅈ | ||
| + | </pre> | ||
| + | 2) | ||
| + | <pre> | ||
| + | 10#SIN | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 0 0.8414709848078965 0.9092974268256817 0.1411200080598672 -0.7568024953079282 -0.9589242746631385 -0.27941549819892586 0.6569865987187891 0.9893582466233818 0.4121184852417566 -0.5440211108893698 | ||
| + | </pre> | ||
| + | 3) | ||
| + | <pre> | ||
| + | 10#"mm" | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | Z3EVAL((10#"mm") | ||
| + | .print())<>cm | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | VALUE 0cm 0.1cm 0.2cm 0.30000000000000004cm 0.4cm 0.5cm 0.6000000000000001cm 0.7000000000000001cm 0.8cm 0.9cm 1cm | ||
| + | </pre> | ||
| + | ====Convert numbers to string==== | ||
| + | 1) | ||
| + | <pre> | ||
| + | 10#"3" | ||
| + | </pre> | ||
| + | Output: | ||
| + | <pre> | ||
| + | 03 13 23 33 43 53 63 73 83 93 103 | ||
| + | </pre> | ||
| + | |||
| + | =See Also= | ||
| + | |||
| + | [[Fabulous_!_Operator | Fabulous ! Operator]] | ||
Latest revision as of 20:51, 3 June 2025
Hash # Operator
Hash Operator (#) can have multiple meanings, when used as a binary operator or as suffix. It can be used to: (1) Arrafy Functions, (2) Index, Search and Filter Arrays, and (3) Index and Search Objects. Hash operator can be used to create lists of numbers, indices, etc., (similar to APL iota), but in far more powerful ways.
# To Arrayfy Functions
Any function can be enabled with Array handling for all (or some) parameters, by using # operator. For example: v:=u+a*t; creates a function v which computes the expression u+a*t, with u, a, and t as parameters. However, this function only takes simple parameters as inputs. To make the function v to be able to compute combinations of arrays as parameters, using Combinatorial Arguments, simply use the notation v# to enable array handling capabilities to each of the parameters. If we wish to exclude any parameter, provide an array of such parameters index as the suffix to #. For example, v#[1] will exclude "a" (the 1st index parameter) from handling input arrays.
Once arrayfied, the function can take arrays as arguments, and for each of the cartesian product of the parameters, a result will be computed. For example, once arrayfied, v(1..2,3..4,1..10) will compute the value for v for each combination of the three parameter arrays.
# To Split Strings
# splits strings into arrays.
If numbers are provided on the right of #, then splits can be done in a pattern. If regular expressions are provided on the right, the splits will be based on the regular expression.
"this"# // Splits this to four separate elements, t, h, i and s. "this"#[3,3] // Splits this to separate elements, of size 3, 3, etc.
# To Index and Extract From Arrays
Hash Operator (#) can be used to index arrays, as below. If the right argument is an array, it will extract all elements represented by the indices on the right. If a multi-dimensional index is required, provide a subarray, such as 2,3 instead of [2,3]. To get the length of elements along a particular dimension, use the notation nd (For example, 1d to extract the size along the 1st dimension).
(1..10)#0..2 (1..10)#2 (1..10)#22 (1..10)#1d // dimension 1st, made to 1-1=0 of size |4|#2d |4|#1d |4|#[2,3] MS(4)#[2,3,6] MS(4)#[2,1] MS(4)#[[2,1]] MS(4)#[2d] // size of 2d MS(4)#[2d,1d] "this"#[3,3] [..4,..5]#[1,0] [..4,..5]#[[1,3]]
(1..12)#2 (1..12)#2..6 (1..12)#/4/ (1..12)#/4/#TRUE
# To Access Object Members
Hash Operator (#) can be used to access members of objects as below.
a={speed:3,weight:34};
a#"speed"
a={speed:3,weight:34};
a#["speed","weight"]
a#; // will arrayfy the object.
// header based with a notation?
a={speed:3,weight:34};
a#[["speed","weight"]]
a=
{speed:3,
weight:34,
details:{color:"red",size:"large"}
};
a#[["speed","weight"],[["details","size"]]] ;
a#[[["details","size"]]] ;
a#["speed","weight"] // this extracts the fields as separate objects
{
"speed": 3
} {
"weight": 34
}
a#"speed","weight" extracts the field values.
3 34
a#[[["details","size"]]] extracts the key subkey details/size.
large
# To Access Object Members from Array of Objects
Hash Operator (#) can be used to access members of objects in an array of objects as below.
a=
[{
"id": 1,
"first_name": "Jeanette",
"last_name": "Penddreth",
"email": "jpenddreth0@census.gov",
"gender": "Female",
"ip_address": "26.58.193.2"
}, {
"id": 2,
"first_name": "Giavani",
"last_name": "Frediani",
"email": "gfrediani1@senate.gov",
"gender": "Male",
"ip_address": "229.179.4.212"
}, {
"id": 3,
"first_name": "Noell",
"last_name": "Bea",
"email": "nbea2@imageshack.us",
"gender": "Female",
"ip_address": "180.66.162.255"
}, {
"id": 4,
"first_name": "Willard",
"last_name": "Valek",
"email": "wvalek3@vk.com",
"gender": "Male",
"ip_address": "67.76.188.26"
}]
a#"email"
a#"id,email,gender"
|
|
| |||
|
|
| |||
|
|
| |||
|
|
|
More Complex Keys and Queries to Arrays of Objects with #
Multiple keys can be comma separated, and subkeys can be separated with periods (.). Example: x#"id,email.official,address.zip" etc., where x is an array of objects with fields and subfields.
Simple numbers for indices will extract the specified objects at such indices. Example: a#1 extracts the element at index 1. a#1..3 gets elements at indices 1 to 3 etc.
These notations can be called from Calcis containing objects in cells etc. Example: =rs#"first_name,email where rs represents an array of objects.
Generating Arrays and Function Application
Hash operator can be powerful when applied to simple numbers.
List below show several ways a number can be arrayfied to give list comprehensions, iota, indices, generation of powerful arrays with function application and lists, etc.
For this behavior, the left side should be a number. The right side can be a number, string, array, function, etc.
The array on the right represents parameters such as start, interval, addition to each element, function to apply to each element etc. The added element can be complex numbers etc., giving extremely powerful list comprehensions with complex structures.
If the right side is a function, that function is applied over the generated series.
Generate array from number
1)
3# // 0 indexed
Output:
012
Generate range starting at number
1)
3#1 // 1..n
Output:
123
2)
3#2 // start at 1
Output:
23
Generate array from variable
1)
n=10; n#
Output:
0123456789
2)
n=10; n#1
Output:
12345678910
4)
10#[-2,1]
Output:
-2-1012345678910
5)
10#[-2,2,100]
Output:
98 100 102 104 106 108 110
6)
10#[-2,2,2]
Output:
0 2 4 6 8 10 12
Custom steps with complex number
1)
n=10; (n#[1,2.3,23i])
Output:
1+23ⅈ 3.3+23ⅈ 5.6+23ⅈ 7.8999999999999995+23ⅈ
2)
n=10; n#[-3,2,34i]
Output:
-3+34ⅈ -1+34ⅈ 1+34ⅈ 3+34ⅈ 5+34ⅈ 7+34ⅈ 9+34ⅈ
3)
30#[1,1,2.3]
Output:
3.3 4.3 5.3 6.3 7.3 8.3 9.3 10.3
4)
n=10; n#[-3,2,34i]
Output:
-3+34ⅈ -1+34ⅈ 1+34ⅈ 3+34ⅈ 5+34ⅈ 7+34ⅈ 9+34ⅈ
5)
30#[0,1]
Output:
0 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 28 29
6)
10#[0,1,SQUARED]
Output:
0 1 4 9 16 25 36 49 64 81
7)
10#[1,1,SQUARED]
Output:
1 4 9 16 25 36 49 64 81 100
8)
10#[0,1,SQUARED]
Output:
0 1 4 9 16 25 36 49 64 81
Nested hash
1)
10#[1,1,10#]
Output:
1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 3 4 5 6 7 8 9 10 11 12 4 5 6 7 8 9 10 11 12 13 5 6 7 8 9 10 11 12 13 14 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 16 8 9 10 11 12 13 14 15 16 17 9 10 11 12 13 14 15 16 17 18 10 11 12 13 14 15 16 17 18 19
2)
10#[0,1,10#]
Output:
0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 3 4 5 6 7 8 9 10 11 12 4 5 6 7 8 9 10 11 12 13 5 6 7 8 9 10 11 12 13 14 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 16 8 9 10 11 12 13 14 15 16 17 9 10 11 12 13 14 15 16 17 18
Apply SIN to series
1)
10#[0,1,[SIN]]
Output:
0.8414709848078965 0.9092974268256817 0.1411200080598672 -0.7568024953079282 -0.9589242746631385 -0.27941549819892586 0.6569865987187891 0.9893582466233818 0.4121184852417566 -0.5440211108893698
2)
10#[0,1,[SQUARED]]
Output:
1 4 9 16 25 36 49 64 81 100
3)
10#[0,1,[1,2,-1,-2,SQUARED]]
Output:
1 2 -1 -2 1 2 3 0 -1 4 3 4 1 0 9 4 5 2 1 16 5 6 3 2 25 6 7 4 3 36 7 8 5 4 49 8 9 6 5 64 9 10 7 6 81 10 11 8 7 100
Generate negative imaginary series
1)
10#-1i
Output:
0-1ⅈ 1-1ⅈ 2-1ⅈ 3-1ⅈ 4-1ⅈ 5-1ⅈ 6-1ⅈ 7-1ⅈ 8-1ⅈ 9-1ⅈ
2)
10#SIN
Output:
0 0.8414709848078965 0.9092974268256817 0.1411200080598672 -0.7568024953079282 -0.9589242746631385 -0.27941549819892586 0.6569865987187891 0.9893582466233818 0.4121184852417566 -0.5440211108893698
3)
10#"mm"
Output:
Z3EVAL((10#"mm") .print())<>cm
Output:
VALUE 0cm 0.1cm 0.2cm 0.30000000000000004cm 0.4cm 0.5cm 0.6000000000000001cm 0.7000000000000001cm 0.8cm 0.9cm 1cm
Convert numbers to string
1)
10#"3"
Output:
03 13 23 33 43 53 63 73 83 93 103