ListTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

ListTools

  

Slice

  

slices a list into a sequence of sub-lists with the number of elements in each sub-list differing by at most one

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

ListTools[Slice]( L, n );

Slice( L, n );

Parameters

L

-

Any list, to be sliced into sub-lists.

n

-

Positive integer, specifying the target number of sub-lists.

Description

• 

As the underlying implementation of the ListTools package is a module, it is also possible to use the form ListTools:-Slice to access the command from the package. For more information, see Module Members.

• 

The command slices a list into a sequence of sub-lists with the number of elements in each sub-list differing by at most one.

• 

If not all the sub-lists are of the same length, the longer lists appear first.

• 

Elements in the returned sequence of sub-lists appear in the same order as the original list.

• 

If the specified number of sub-lists is greater than the number of elements in the original list, then the list is sliced into sub-lists of single elements, followed by empty sub-lists.

Examples

withListTools:

Slice,1

(1)

Slice,2

,

(2)

La,b,c,d,e

La,b,c,d,e

(3)

SliceL,1

a,b,c,d,e

(4)

SliceL,2

a,b,c,d,e

(5)

SliceL,3

a,b,c,d,e

(6)

SliceL,4

a,b,c,d,e

(7)

SliceL,5

a,b,c,d,e

(8)

SliceL,6

a,b,c,d,e,

(9)

Compatibility

• 

The ListTools[Slice] command was introduced in Maple 2020.

• 

For more information on Maple 2020 changes, see Updates in Maple 2020.

See Also

ListTools

ListTools[LengthSplit]