aa_macro syntax 
 aa_macro source 
 HTML source 
 HTML render 

4.53 - [lslice] Built-In

Mnemonic aid: lslice for one List SLICEd into another

See also:  [aisort] ,  [append] ,  [asort] ,  [clearl] ,  [cmap] ,  [dlist] ,  [e] ,  [hmap] ,  [isort] ,  [lcc] ,  [lcopy] ,  [lhsort] ,  [list] ,  [ljoin] ,  [llen] ,  [lpop] ,  [lset] ,  [lsplit] ,  [lsub] ,  [ltol]  and  [translate] 

Slices one list into another, or the same, list. sliceSpec can be any of the following, where a, b and c are integers::

a ------pulls that element out of the list
a:b ----pulls from a to b-1
a:b:c --pulls from a to b-1, stepping by c
:b -----pulls from beginning to b-1
a: -----pulls from a to end
::c ----pulls from beginning to end, stepping by c
:b:c ---pulls from beginning to b-1, stepping by c
a::c ---pulls from a to end, stepping by c
Tip: When a slice component a or b is negative, then it refers to a list element relative to the end of the list. When c is negative, the step goes from the end of the list towards the beginning of the list.

[lslice sliceSpec,srcList,tgtList]

[list srclist,a,b,c,d]
[lslice 1:3,srclist,tgtlist]
[dlist tgtlist]

[list srclist,a,b,c,d]
[lslice :2,srclist,tgtlist]
[dlist tgtlist]

[list srclist,a,b,c,d]
[lslice 2,srclist,tgtlist]
[dlist tgtlist]

[list srclist,a,b,c,d]
[lslice ::-1,srclist,tgtlist]
[dlist tgtlist]

bc ab c dcba

Other built-ins used here:  [dlist]  and  [list] 

Keyboard Navigation
, Previous Page . Next Page t TOC i Index

Valid HTML 4.01 Loose

This manual was generated with wtfm
wtfm uses aa_macro and SqLite
aa_macro uses python 2.7