index

File index.str
Author unknown
Since unknown

This module contains strategies for working on lists using indexes.An indexed list works similarly to an array in that every element ofthe list is associated with in an integer index, and the first element has index 1.

Adding the indices to a list is done by add-indices.




Statistics


General
Lines of code 166
Stratego
Module number 1 (100% documented)
Constructor number 0
Overlay number 0
Strategy number 12 (91% documented)
Rule number 6 (100% documented)
DynamicRule number 0



Strategy summary


add-indices Adds indices to the elements of a list index.str
at-index(Strategy s) Apply s at the specified index The first element has index 0 index.str
at-index(Strategy s, ATerm i) Apply s at the specified index i index.str
at-index-tail(Strategy s, ATerm i) Apply s to the list containing the elements from index i onwards from the original list index.str
get-index Get index of element in list index.str
get-index0(Strategy s) n/a index.str
index Get the n-th element of a list index.str
index(ATerm i) Get the i-th element of a list index.str
insert Insert element in list index.str
map-with-index(Strategy s) Apply strategies that require some knowledge of the index of an element to the elements of the list index.str
nmap(Strategy s, ATerm i) Map a strategy over a list where the strategy takes the index as a term argument index.str
set-index Change element in list index.str



Strategy details


ATerm add-indices
File index.str
Author unknown
Since unknown
 

Adds indices to the elements of a list.The index of the first element is 1.

Example: <add-indices> [1,2,3] => [(1,1),(2,2),(3,3)]


type List(a) -> List((Int, a))

 
ATerm at-index(Strategy s)
File index.str
Author unknown
Since unknown
 

Apply s at the specified indexThe first element has index 0.


type (Int, List(a)) -> List(a)

 
ATerm at-index(Strategy s, ATerm i)
File index.str
Author unknown
Since unknown
 

Apply s at the specified index i.The first element has index 0.


type List(a)) -> List(a)

 
ATerm at-index-tail(Strategy s, ATerm i)
File index.str
Author unknown
Since unknown
 

Apply s to the list containing the elementsfrom index i onwards from the original list.The first element has index 0.


type List(a) -> List(a)

 
ATerm get-index
File index.str
Author unknown
Since unknown
 

Get index of element in list.


type (a, List(a)) -> Int

 
ATerm index
File index.str
Author unknown
Since unknown
 

Get the n-th element of a list.The first element has index 1.


type (Int, List(a)) -> a

 
ATerm index(ATerm i)
File index.str
Author unknown
Since unknown
 

Get the i-th element of a list.The first element has index 1.


type List(a) -> a

 
ATerm insert
File index.str
Author unknown
Since unknown
 

Insert element in list.


type (Int, a, List(a)) -> List(a)

 
ATerm map-with-index(Strategy s)
File index.str
Author unknown
Since unknown
 
Parameters
Strategy s Int * a -> b

Apply strategies that require some knowledge of the index of an element to the elements of the list.

The index of the first element is 1.


type List(a) -> List(b)

 
ATerm nmap(Strategy s, ATerm i)
File index.str
Author unknown
Since unknown
 
Parameters
Strategy s Strategy to apply to all the elements of the list.
ATerm i The first index (e.g. 0 or 1)

Map a strategy over a list where the strategy takes the index as a term argument.


type List(a) -> List(b)

 
ATerm set-index
File index.str
Author unknown
Since unknown
 

Change element in list.The first element has index 0.


type (Int, a, List(a)) -> List(a)