Difference between revisions of "Array Manipulation"

From ZCubes Wiki
Jump to navigation Jump to search
(19 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
*[[ Z3 | << Z3 Home ]]
 
*[[ Z3 | << Z3 Home ]]
 
*[[ Z%5E3_Language_Documentation | Z3 Language Documentation]]
 
*[[ Z%5E3_Language_Documentation | Z3 Language Documentation]]
 +
*[[ Z%5E3_Array_Manipulation_Member_Functions | Listing of Z3 Array Manipulation Member Functions]]
 +
  
  
Line 47: Line 49:
  
 
b=a.chunks(10)
 
b=a.chunks(10)
b.$$(SUM)
+
</br>b.$$(SUM)
  
 
{| class="wikitable"|-
 
{| class="wikitable"|-
Line 72: Line 74:
  
  
*[[ Z3 | << Z3 Home ]]
 
*[[ Z%5E3_Language_Documentation | Z3 Language Documentation]]
 
 
==ARRAY FUNCTIONS==
 
A listing of the Array functions are given below:
 
 
Function name  Parameter
 
{|border="1" cellpadding="5" cellspacing="0"
 
|-
 
! Function Name !! Parameters
 
|-
 
| $ ||
 
|-
 
| $$ ||
 
|-
 
| $$$ ||
 
|-
 
| $$F ||
 
|-
 
| $A || Parameter
 
|-
 
| $C ||
 
|-
 
| $CELLS ||
 
|-
 
| $R ||
 
|-
 
| $X ||
 
|-
 
| $_ ||
 
|-
 
| $d ||
 
|-
 
| $diag ||
 
|-
 
| $dth ||
 
|-
 
| $x ||
 
|-
 
| X$ ||
 
|-
 
| ZJSON ||
 
|-
 
| __$ ||
 
|-
 
| ac ||
 
|-
 
| accumulate || Total
 
|-
 
| accumulatewith || CumulateFunction,CurrentResult
 
|-
 
| across ||
 
|-
 
| add ||
 
|-
 
| addcolumn ||
 
|-
 
| addrow ||
 
|-
 
| addsequence ||
 
|-
 
| adjoint ||
 
|-
 
| aggregate ||
 
|-
 
| any ||
 
|-
 
| appendfunction ||
 
|-
 
| ar ||
 
|-
 
| async ||
 
|-
 
| atindex ||
 
|-
 
| atnode ||
 
|-
 
| backward ||
 
|-
 
| bindcolumn ||
 
|-
 
| branch ||
 
|-
 
| branchvalues ||
 
|-
 
| c ||
 
|-
 
| calci ||
 
|-
 
| car ||
 
|-
 
| cartesianproduct ||
 
|-
 
| cdr ||
 
|-
 
| cell ||
 
|-
 
| cells ||
 
|-
 
| checktype ||
 
|-
 
| chunks ||
 
|-
 
| ci ||
 
|-
 
| clean ||
 
|-
 
| clear ||
 
|-
 
| clearcopy ||
 
|-
 
| clearrepeats ||
 
|-
 
| clone ||
 
|-
 
| colconcat ||
 
|-
 
| colcount ||
 
|-
 
| collect ||
 
|-
 
| collectasvector ||
 
|-
 
| collectwhile ||
 
|-
 
| collectwhileasvector ||
 
|-
 
| column ||
 
|-
 
| columnconcat ||
 
|-
 
| columns ||
 
|-
 
| compare ||
 
|-
 
| concatall ||
 
|-
 
| converge ||
 
|-
 
| copy ||
 
|-
 
| core ||
 
|-
 
| count ||
 
|-
 
| crosstab ||
 
|-
 
| cube ||
 
|-
 
| cumcolumn ||
 
|-
 
| cumcolumns ||
 
|-
 
| cumcolumnswith ||
 
|-
 
| cumcolumnwith ||
 
|-
 
| cumrow ||
 
|-
 
| cumrows ||
 
|-
 
| cumrowswith ||
 
|-
 
| cumrowwith ||
 
|-
 
| cumulate ||
 
|-
 
| data ||
 
|-
 
| dc ||
 
|-
 
| deal ||
 
|-
 
| deepcopy ||
 
|-
 
| deletecolumn ||
 
|-
 
| deleterow ||
 
|-
 
| det ||
 
|-
 
| determinant ||
 
|-
 
| dim ||
 
|-
 
| div ||
 
|-
 
| divide ||
 
|-
 
| dr ||
 
|-
 
| drop ||
 
|-
 
| dropwhile ||
 
|-
 
| dropwhileasvector ||
 
|-
 
| eighteenth ||
 
|-
 
| eighth ||
 
|-
 
| eleventh ||
 
|-
 
| equal ||
 
|-
 
| equalvalues ||
 
|-
 
| eval ||
 
|-
 
| except ||
 
|-
 
| exec ||
 
|-
 
| explode ||
 
|-
 
| extract ||
 
|-
 
| few ||
 
|-
 
| fifteenth ||
 
|-
 
| fifth ||
 
|-
 
| fillwith ||
 
|-
 
| filtermatches ||
 
|-
 
| filteroncolumn ||
 
|-
 
| filteroncondition ||
 
|-
 
| filteronrow ||
 
|-
 
| findcellref ||
 
|-
 
| first ||
 
|-
 
| firstelement ||
 
|-
 
| firsthalf ||
 
|-
 
| fixat ||
 
|-
 
| fjoin ||
 
|-
 
| flatten ||
 
|-
 
| flip ||
 
|-
 
| flipparts ||
 
|-
 
| fold ||
 
|-
 
| foldl ||
 
|-
 
| foldr ||
 
|-
 
| forward ||
 
|-
 
| fourteenth ||
 
|-
 
| fourth ||
 
|-
 
| fourths ||
 
|-
 
| funcjoin ||
 
|-
 
| gettype ||
 
|-
 
| graph ||
 
|-
 
| graphin ||
 
|-
 
| half ||
 
|-
 
| halves ||
 
|-
 
| hderef ||
 
|-
 
| head ||
 
|-
 
| headings ||
 
|-
 
| hindex ||
 
|-
 
| hundredth ||
 
|-
 
| i ||
 
|-
 
| ic ||
 
|-
 
| ids ||
 
|-
 
| implode ||
 
|-
 
| inc ||
 
|-
 
| include ||
 
|-
 
| indices ||
 
|-
 
| injoin ||
 
|-
 
| insert ||
 
|-
 
| insertcolumn ||
 
|-
 
| insertrow ||
 
|-
 
| inverse ||
 
|-
 
| ir ||
 
|-
 
| is ||
 
|-
 
| is1d ||
 
|-
 
| is2d ||
 
|-
 
| isFalse ||
 
|-
 
| isTrue ||
 
|-
 
| islikelytype ||
 
|-
 
| isnotnull ||
 
|-
 
| isnull ||
 
|-
 
| istype ||
 
|-
 
| j ||
 
|-
 
| joincolumnswith ||
 
|-
 
| joinrowswith ||
 
|-
 
| joinwith ||
 
|-
 
| jq ||
 
|-
 
| keep ||
 
|-
 
| last ||
 
|-
 
| lastelement ||
 
|-
 
| list ||
 
|-
 
| lookup ||
 
|-
 
| make ||
 
|-
 
| make1to2d ||
 
|-
 
| makecore ||
 
|-
 
| makekeyarray ||
 
|-
 
| maplist ||
 
|-
 
| mapper ||
 
|-
 
| maprow ||
 
|-
 
| mask ||
 
|-
 
| match ||
 
|-
 
| matchcolumn ||
 
|-
 
| matchindex ||
 
|-
 
| matchrow ||
 
|-
 
| matchvalue ||
 
|-
 
| merge ||
 
|-
 
| mergecolumns ||
 
|-
 
| mergeio ||
 
|-
 
| mergerows ||
 
|-
 
| mid ||
 
|-
 
| millionth ||
 
|-
 
| multiply ||
 
|-
 
| nicejoin ||
 
|-
 
| nineteenth ||
 
|-
 
| nineth ||
 
|-
 
| nodeindex ||
 
|-
 
| notinclude ||
 
|-
 
| notwithinlimits ||
 
|-
 
| nth ||
 
|-
 
| ntimes ||
 
|-
 
| nullifyobjects ||
 
|-
 
| numbers ||
 
|-
 
| o ||
 
|-
 
| objects ||
 
|-
 
| of ||
 
|-
 
| otherthan ||
 
|-
 
| pack ||
 
|-
 
| pad ||
 
|-
 
| pair ||
 
|-
 
| pairmatch ||
 
|-
 
| partitiononcondition ||
 
|-
 
| parts ||
 
|-
 
| pastefolds ||
 
|-
 
| pick ||
 
|-
 
| pieces ||
 
|-
 
| pip ||
 
|-
 
| pipall ||
 
|-
 
| pipallwithslice ||
 
|-
 
| plot ||
 
|-
 
| prefix ||
 
|-
 
| primitives ||
 
|-
 
| print ||
 
|-
 
| printf ||
 
|-
 
| r ||
 
|-
 
| rand ||
 
|-
 
| random ||
 
|-
 
| remove ||
 
|-
 
| removeByVal ||
 
|-
 
| removeindices ||
 
|-
 
| removewith ||
 
|-
 
| repeatntimes ||
 
|-
 
| replace ||
 
|-
 
| replicate ||
 
|-
 
| rest ||
 
|-
 
| result ||
 
|-
 
| reverselevel ||
 
|-
 
| reversepip ||
 
|-
 
| reversesort ||
 
|-
 
| ri ||
 
|-
 
| rotate ||
 
|-
 
| rotatecolumns ||
 
|-
 
| rotaterows ||
 
|-
 
| row ||
 
|-
 
| rowconcat ||
 
|-
 
| rowcount ||
 
|-
 
| rowlengths ||
 
|-
 
| rowpush ||
 
|-
 
| rows ||
 
|-
 
| rslice ||
 
|-
 
| second ||
 
|-
 
| secondhalf ||
 
|-
 
| seq ||
 
|-
 
| set ||
 
|-
 
| setHeadings ||
 
|-
 
| setaxis ||
 
|-
 
| setcolumn ||
 
|-
 
| setrow ||
 
|-
 
| setunit ||
 
|-
 
| seventeenth ||
 
|-
 
| seventh ||
 
|-
 
| shiftlevel ||
 
|-
 
| shuffle ||
 
|-
 
| sixteenth ||
 
|-
 
| sixth ||
 
|-
 
| size ||
 
|-
 
| size2d ||
 
|-
 
| slices ||
 
|-
 
| slides ||
 
|-
 
| sortrecursively ||
 
|-
 
| sortwith ||
 
|-
 
| specialprint ||
 
|-
 
| spliteach ||
 
|-
 
| splitwhile ||
 
|-
 
| splitwhileasvector ||
 
|-
 
| stringlist ||
 
|-
 
| subtract ||
 
|-
 
| suchthat ||
 
|-
 
| suchthatasvector ||
 
|-
 
| suffix ||
 
|-
 
| t ||
 
|-
 
| table ||
 
|-
 
| tablelookup ||
 
|-
 
| tail ||
 
|-
 
| takewhile ||
 
|-
 
| takewhileasvector ||
 
|-
 
| tenth ||
 
|-
 
| third ||
 
|-
 
| thirds ||
 
|-
 
| thirteenth ||
 
|-
 
| thousandth ||
 
|-
 
| tofunctions ||
 
|-
 
| toobjectformat ||
 
|-
 
| totree ||
 
|-
 
| transpose ||
 
|-
 
| truefalse ||
 
|-
 
| twelfth ||
 
|-
 
| twentieth ||
 
|-
 
| twod ||
 
|-
 
| type ||
 
|-
 
| uncrosstab ||
 
|-
 
| unimplode ||
 
|-
 
| unimplodeleaf ||
 
|-
 
| unitsof ||
 
|-
 
| unwrapleaf ||
 
|-
 
| unzip ||
 
|-
 
| value ||
 
|-
 
| where ||
 
|-
 
| withinlimits ||
 
|-
 
| withouttail ||
 
|-
 
| x$ ||
 
|-
 
| xy ||
 
|-
 
| xypanel ||
 
|-
 
| z3 ||
 
|-
 
| zero ||
 
|-
 
| zip ||
 
|-
 
| zoompip ||
 
|-
 
|㪭㭲 ||
 
  
|}
 
  
  
 +
*[[ Z%5E3_Array_Manipulation_Member_Functions | Listing of Z3 Array Manipulation Member Functions]]
 
*[[ Z%5E3_Language_Documentation | Z3 Language Documentation]]
 
*[[ Z%5E3_Language_Documentation | Z3 Language Documentation]]
 
*[[ Z3 | << Z3 Home ]]
 
*[[ Z3 | << Z3 Home ]]

Revision as of 20:42, 14 May 2020

Introduction to Array Manipulation


Arrays/Sets/Matrices are fundamental data structures in z^3. Manipulation of such data structures are often done using custom code in most languages. However, z^3 offers a ton of Array member functions that make it a breeze to handle and manipulate such data structures.

For example, take .chunks().

a=1..100;

This creates a list of 100 numbers. Now, let us make them into chunks of 10 each.

a.chunks(10)

gives

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 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 100


Simple, isn't it?

The result gives a 10x10 matrix filled with the sequence of numbers from 1 to 100.

Let us say we want to calculate the sum of each row in this 10x10 matrix. The $$ row wise mapping function comes to the rescue.

b=a.chunks(10)
b.$$(SUM)

55
155
255
355
455
555
655
755
855
955