ListTools - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : ListTools Package : ListTools/LengthSplit

ListTools

  

LengthSplit

  

split a list into an expression sequence of sublists of a given length

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

LengthSplit( L, n )

LengthSplit( L, n, pad = expr )

Parameters

L

-

list

n

-

posint; the length of the sublists

expr

-

(optional) anything; an expression to use for padding the last list to length n

Description

• 

The LengthSplit command splits a list L into a sequence of sublists, each with n elements. If n does not divide evenly into nopsL, then the final sublist will have iremnopsL,n elements, unless the pad=expr option is given, in which case the value of expr will be used to fill out the final sublist to length n. If n divides evenly into nopsL, then the pad option has no effect.

Examples

withListTools:

Lseqi,i=1..12

L:=1,2,3,4,5,6,7,8,9,10,11,12

(1)

LengthSplitL,3

1,2,3,4,5,6,7,8,9,10,11,12

(2)

LengthSplitL,4

1,2,3,4,5,6,7,8,9,10,11,12

(3)

LengthSplitL,5

1,2,3,4,5,6,7,8,9,10,11,12

(4)

LengthSplitL,5,'pad'=x

1,2,3,4,5,6,7,8,9,10,11,12,x,x,x

(5)

See Also

list

ListTools

ListTools[Split]

StringTools[LengthSplit]

type[list]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam