Difference between revisions of "Array Manipulation"

From ZCubes Wiki
Jump to navigation Jump to search
 
(15 intermediate revisions by 4 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]]
 +
*[[ Z%5E3_Map_Reduce | Map Reduce]]
 +
 +
  
  
Line 47: Line 51:
  
 
b=a.chunks(10)
 
b=a.chunks(10)
b.$$(SUM)
+
</br>b.$$(SUM)
  
 
{| class="wikitable"|-
 
{| class="wikitable"|-
Line 72: Line 76:
  
  
*[[ 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 || OtherArray, Function
 
|-
 
| add || Thing
 
|-
 
| addcolumn || NumberOfColumns
 
|-
 
| addrow || NumberOfRows
 
|-
 
| addsequence || InFront,StartFrom,OptionalSequenceArray
 
|-
 
| adjoint || Array
 
|-
 
| aggregate || Columns,Function, Params
 
|-
 
| any || Count
 
|-
 
| appendfunction || Function
 
|-
 
| ar ||
 
|-
 
| async || Iterator, CallBack
 
|-
 
| atindex ||
 
|-
 
| atnode || Function,SubtractByArray,ScaleByArray,DoNotShowIndices
 
|-
 
| backward || Function, StartValue
 
|-
 
| bindcolumn ||
 
|-
 
| branch ||
 
|-
 
| branchvalues ||
 
|-
 
| c ||
 
|-
 
| calci ||
 
|-
 
| car ||
 
|-
 
| cartesianproduct || IsWithoutFlatten
 
|-
 
| cdr ||
 
|-
 
| cell || Row, Column, Width, Height
 
|-
 
| cells ||
 
|-
 
| checktype || TypeArray,ForceCheckOnVariables
 
|-
 
| chunks || ChunkSize
 
|-
 
| ci ||
 
|-
 
| clean || Expression, ReplaceWith
 
|-
 
| clear || FillWith
 
|-
 
| clearcopy || FillWith
 
|-
 
| clearrepeats ||
 
|-
 
| clone ||
 
|-
 
| colconcat ||
 
|-
 
| colcount ||
 
|-
 
| collect ||
 
|-
 
| collectasvector ||
 
|-
 
| collectwhile ||
 
|-
 
| collectwhileasvector ||
 
|-
 
| column ||
 
|-
 
| columnconcat ||
 
|-
 
| columns ||
 
|-
 
| compare ||
 
|-
 
| concatall || LimitArray, IncludeEdges
 
|-
 
| converge || Function, NumberOfIterations, Accuracy, Converge
 
|-
 
| copy ||
 
|-
 
| core ||
 
|-
 
| count || FirstLevelOnly
 
|-
 
| crosstab || RowSet, ColSet,PageSet,DataSet
 
|-
 
| cube ||
 
|-
 
| cumcolumn ||
 
|-
 
| cumcolumns ||
 
|-
 
| cumcolumnswith ||
 
|-
 
| cumcolumnwith ||
 
|-
 
| cumrow ||
 
|-
 
| cumrows ||
 
|-
 
| cumrowswith ||
 
|-
 
| cumrowwith ||
 
|-
 
| cumulate ||
 
|-
 
| data ||
 
|-
 
| dc ||
 
|-
 
| deal || Within, ManyInEach
 
|-
 
| deepcopy ||
 
|-
 
| deletecolumn || Where
 
|-
 
| deleterow || Where
 
|-
 
| det || Array
 
|-
 
| determinant ||
 
|-
 
| dim ||
 
|-
 
| div ||
 
|-
 
| divide ||
 
|-
 
| dr ||
 
|-
 
| drop ||
 
|-
 
| dropwhile ||
 
|-
 
| dropwhileasvector ||
 
|-
 
| eighteenth ||
 
|-
 
| eighth ||
 
|-
 
| eleventh ||
 
|-
 
| equal || Array, CheckLength, StartFrom
 
|-
 
| equalvalues || Array, CheckLength, StartFrom
 
|-
 
| eval ||
 
|-
 
| except ||
 
|-
 
| exec ||
 
|-
 
| explode || StartIndex, By, RecurseTillLevel
 
|-
 
| extract ||
 
|-
 
| few ||
 
|-
 
| fifteenth || Function
 
|-
 
| fifth ||
 
|-
 
| fillwith ||
 
|-
 
| filtermatches || MatchIdenticalMatrix, OnlyMatches
 
|-
 
| filteroncolumn || Condition, ExtractColumns, FilterOnColumn
 
|-
 
| filteroncondition || TakeDropOrAllFlag, Function, Parameter
 
|-
 
| filteronrow || Condition, ExtractColumns, FilterOnColumn
 
|-
 
| findcellref || Values
 
|-
 
| first || Count
 
|-
 
| firstelement || Count
 
|-
 
| firsthalf ||
 
|-
 
| fixat || Index,Fix
 
|-
 
| fjoin || HeadLength, JoinString
 
|-
 
| flatten ||
 
|-
 
| flip ||
 
|-
 
| flipparts ||
 
|-
 
| fold || AtFoldValue, AtReverseFoldValue
 
|-
 
| foldl || Function, StartSeed
 
|-
 
| foldr || Function, StartSeed
 
|-
 
| forward || Function, StartValue
 
|-
 
| fourteenth ||
 
|-
 
| fourth ||
 
|-
 
| fourths ||
 
|-
 
| funcjoin || HeadLength, FindString, FirstString, MidString, LastString
 
|-
 
| gettype ||
 
|-
 
| graph || Mode
 
|-
 
| graphin ||
 
|-
 
| half ||
 
|-
 
| halves ||
 
|-
 
| hderef || Array
 
|-
 
| head ||
 
|-
 
| headings ||
 
|-
 
| hindex ||
 
|-
 
| hundredth ||
 
|-
 
| i || PreviousArray
 
|-
 
| ic ||
 
|-
 
| ids ||
 
|-
 
| implode || RecurseTillLevel
 
|-
 
| inc ||
 
|-
 
| include ||
 
|-
 
| indices || Function,SubtractByArray,ScaleByArray,DoNotShowIndices,RowArray
 
|-
 
| injoin || JoinWith
 
|-
 
| insert || Value, AfterLastFlag
 
|-
 
| insertcolumn || Index, NumberOfColumns
 
|-
 
| insertrow || Index, NumberOfRows
 
|-
 
| inverse || Array
 
|-
 
| ir ||
 
|-
 
| is || Thing, IsNot
 
|-
 
| is1d ||
 
|-
 
| is2d ||
 
|-
 
| isFalse ||
 
|-
 
| isTrue ||
 
|-
 
| islikelytype ||
 
|-
 
| isnotnull ||
 
|-
 
| isnull ||
 
|-
 
| istype ||
 
|-
 
| j ||
 
|-
 
| joincolumnswith || ArrayOfJoinCharacters,IsRepeat
 
|-
 
| joinrowswith || ArrayOfJoinCharacters,IsRepeat
 
|-
 
| 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 ]]

Latest revision as of 09:13, 31 December 2021

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