Command: Partition

NEST HelpDesk Command Index NEST Quick Reference

Name:
 Partition - Partition list into n element pieces

Synopsis:
     array n Partition
     array n d 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.
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  ->  []


Diagnostics:
     Raises error if n<0 or d<1

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

Author:
 Gewaltig, Diesmann

FirstVersion:
  Jun 29 1999, Marc-Oliver Gewaltig

References:
 "The Mathematica Book"
SeeAlso:Flatten
Source:
 /home/abuild/rpmbuild/BUILD/nest-2.4.1/lib/sli/mathematica.sli

NEST HelpDesk Command Index NEST Quick Reference

© 2000-2010 The NEST Initiative