Difference between revisions of "Array.pip()"

From ZCubes Wiki
Jump to navigation Jump to search
Line 38: Line 38:
 
[5,1 ]
 
[5,1 ]
 
],
 
],
 +
 +
[4,3,8 ]
 +
]
 +
 +
 +
MAGICSQUARE(3).pip([1,1],2,x=>SUM(x)).print()
 +
 +
[
 +
[2,7,6 ],
 +
 +
[9,6 ],
  
 
[4,3,8 ]
 
[4,3,8 ]
 
]
 
]

Revision as of 11:11, 5 February 2020

Array.pip(SomePathIndexArray, SomeLength, SomePassThroughFunction)

  • pip is push plus insert. The array is split at the nodes in SomePathIndexArray, and a slice of length SomeLength is pushed into these array indices, and the values are massaged with SomePassThroughFunction if provided.
  • pip modifies the original array.
  • SomePathIndexArray is array indices to refer to a specific cell in the array to be pip-ed.

Example: 1..10.pip(5,2)

1

2

3

4

5

6 7

8

9

10

MAGICSQUARE(3).pip([1,1],2).print()

[ [2,7,6 ],

[9, [5,1 ] ],

[4,3,8 ] ]


MAGICSQUARE(3).pip([1,1],2,x=>SUM(x)).print()

[ [2,7,6 ],

[9,6 ],

[4,3,8 ] ]