Partition

Command: Partition


Description

Partition works like the corresponding Mathematica function. Partition
creates subarrays with n elements and offset d.

Parameters

n - length of subarray.
d - offset of subarray defaults to n.
Author
Gewaltig Diesmann

Synopsis

array n Partition
array n d Partition

References
"The Mathematica Book"
Examples


[1 2 3 4 5 6 7 8 9 10] 2 2 Partition -> [[1 2] [3 4] [5 6] [7 8] [9 10]]
[1 2 3 4 5 6 7 8 9 10] 1 2 Partition -> [[1] [3] [5] [7] [9] [10]]
[1 2 3 4 5 6 7 8 9 10] 2 1 Partition ->
[[1 2] [2 3] [3 4] [4 5] [5 6] [6 7] [7 8] [8 9] [9 10]]

[4 5 6 7 8] 2 Partition -> [[4 5] [6 7]]
[4 5 6] 2 5 Partition -> [[4 5]]
[4 5 6] 5 1 Partition -> []
[4 5 6] 5 7 Partition -> []


File
lib/sli/mathematica.sli
Diagnostics

Raises error if n<0 or d<1

Remarks
Still implements only part of Mathematica's functionality.

FirstVersion
Jun 29 1999 Marc-Oliver Gewaltig

SeeAlso