Partition


Name:
Partition - Partition list into n element pieces
Synopsis:
 
array n Partition
array n d Partition

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 -> []


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.
Diagnostics:
 
Raises error if n<0 or d<1

Remarks:
Still implements only part of Mathematica's functionality.  

References:
"The Mathematica Book"  
Author:
Gewaltig, Diesmann  

FirstVersion: Jun 29 1999, Marc-Oliver Gewaltig

SeeAlso: Source:
/home/graber/work-nest/nest-git/nest-simulator/lib/sli/mathematica.sli