Difference between revisions of "Array Manipulation"

From ZCubes Wiki
Jump to navigation Jump to search
(11 intermediate revisions by 2 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 || 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 || Count
 
|-
 
| lastelement || Count
 
|-
 
| list ||
 
|-
 
| lookup ||
 
|-
 
| make ||
 
|-
 
| make1to2d || ReplaceOriginal
 
|-
 
| makecore ||
 
|-
 
| makekeyarray || Recursive
 
|-
 
| maplist || fun
 
|-
 
| mapper || Function
 
|-
 
| maprow || Function
 
|-
 
| mask ||
 
|-
 
| match || Expression
 
|-
 
| matchcolumn || Expression, Column
 
|-
 
| matchindex || Expression, IndexThenFromMatch
 
|-
 
| matchrow || Expression, Row
 
|-
 
| matchvalue || Expression, IndexThenFromMatch
 
|-
 
| merge || OtherArray, Function
 
|-
 
| mergecolumns || OtherArray
 
|-
 
| mergeio ||
 
|-
 
| mergerows ||
 
|-
 
| mid || From,Count
 
|-
 
| millionth ||
 
|-
 
| multiply ||
 
|-
 
| nicejoin || JoinString, EndString, SubArrayString
 
|-
 
| nineteenth ||
 
|-
 
| nineth ||
 
|-
 
| nodeindex ||
 
|-
 
| notinclude || Item
 
|-
 
| notwithinlimits || LimitArray, IncludeEdges
 
|-
 
| nth || Nth, Count
 
|-
 
| ntimes || Function, NumberOfIterations, Accuracy, Converge
 
|-
 
| nullifyobjects || Recursive
 
|-
 
| numbers || ForceCheckOnVariables
 
|-
 
| o ||
 
|-
 
| objects ||
 
|-
 
| of ||
 
|-
 
| otherthan || ArrayWithElementsToExclude
 
|-
 
| pack ||
 
|-
 
| pad || Length, PadString
 
|-
 
| pair || Value, OnRight
 
|-
 
| pairmatch || AtFoldValue, AtReverseFoldValue, StartFrom
 
|-
 
| partitiononcondition || TakeDropOrAllFlag, Function, Parameter
 
|-
 
| parts || NumberOfParts, SpecificPart
 
|-
 
| pastefolds || MidOnly
 
|-
 
| pick || StyleString, JoinString
 
|-
 
| pieces ||  Width, Function
 
|-
 
| pip ||
 
|-
 
| pipall ||
 
|-
 
| pipallwithslice ||
 
|-
 
| plot ||
 
|-
 
| prefix ||
 
|-
 
| primitives ||
 
|-
 
| print ||
 
|-
 
| printf ||
 
|-
 
| r ||
 
|-
 
| rand ||
 
|-
 
| random || Base,Numbers
 
|-
 
| remove ||
 
|-
 
| removeByVal || Value
 
|-
 
| removeindices ||
 
|-
 
| removewith ||
 
|-
 
| repeatntimes || Function, NumberOfIterations, Accuracy, Converge
 
|-
 
| replace || ExpressionArrayOrValues, ReplaceWith
 
|-
 
| replicate || Count
 
|-
 
| rest || Start, Count
 
|-
 
| result ||
 
|-
 
| reverselevel || Level
 
|-
 
| reversepip ||
 
|-
 
| reversesort || Function
 
|-
 
| ri ||
 
|-
 
| rotate || NumberOfSteps
 
|-
 
| rotatecolumns || NumberOfSteps
 
|-
 
| rotaterows || NumberOfSteps
 
|-
 
| row ||
 
|-
 
| rowconcat || OtherArray
 
|-
 
| rowcount ||
 
|-
 
| rowlengths || Function
 
|-
 
| rowpush || OtherArray
 
|-
 
| rows ||
 
|-
 
| rslice ||
 
|-
 
| second ||
 
|-
 
| secondhalf ||
 
|-
 
| seq || StartIndex, By
 
|-
 
| set ||
 
|-
 
| setHeadings ||
 
|-
 
| setaxis || Axis, ColumnValues
 
|-
 
| setcolumn || Column, ColumnValues
 
|-
 
| setrow || Row, Array
 
|-
 
| setunit ||
 
|-
 
| seventeenth ||
 
|-
 
| seventh ||
 
|-
 
| shiftlevel || Level, NumberOfTimes
 
|-
 
| shuffle ||
 
|-
 
| sixteenth ||
 
|-
 
| sixth ||
 
|-
 
| size ||
 
|-
 
| size2d ||
 
|-
 
| slices || SliceExpression
 
|-
 
| slides ||
 
|-
 
| sortrecursively ||
 
|-
 
| sortwith ||
 
|-
 
| specialprint || Trimmed,TabLevel
 
|-
 
| spliteach || SplitExpression, RetainSplitterAlsoInResult
 
|-
 
| splitwhile ||
 
|-
 
| splitwhileasvector ||
 
|-
 
| stringlist ||
 
|-
 
| subtract ||
 
|-
 
| suchthat ||
 
|-
 
| suchthatasvector ||
 
|-
 
| suffix ||
 
|-
 
| t ||
 
|-
 
| table ||
 
|-
 
| tablelookup || RowValueMatch, ColumnValueMatch
 
|-
 
| tail ||
 
|-
 
| takewhile ||
 
|-
 
| takewhileasvector ||
 
|-
 
| tenth ||
 
|-
 
| third ||
 
|-
 
| thirds ||
 
|-
 
| thirteenth ||
 
|-
 
| thousandth ||
 
|-
 
| tofunctions ||
 
|-
 
| toobjectformat ||
 
|-
 
| totree ||
 
|-
 
| transpose || IncludeHeader
 
|-
 
| truefalse || IsCheckTrueFunctionList,IsCheckFalseFunctionList,DoFlattenFirst
 
|-
 
| twelfth ||
 
|-
 
| twentieth ||
 
|-
 
| twod ||
 
|-
 
| type ||
 
|-
 
| uncrosstab || UptoColumn
 
|-
 
| unimplode || RecurseTillLevel
 
|-
 
| unimplodeleaf ||
 
|-
 
| unitsof ||
 
|-
 
| unwrapleaf ||
 
|-
 
| unzip ||
 
|-
 
| value || Function
 
|-
 
| where || Term
 
|-
 
| withinlimits || LimitArray, IncludeEdges
 
|-
 
| withouttail ||
 
|-
 
| x$ || FunctionArray, OffsetArray, ScaleArray, GiveIndicesAlso,DoCentering
 
|-
 
| xy ||
 
|-
 
| xypanel || FunctionArray, OffsetArray, ScaleArray, GiveIndicesAlso
 
|-
 
| z3 ||
 
|-
 
| zero || ValueInstead, PreserveStructure
 
|-
 
| zip || OtherArray
 
|-
 
| 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