integer

File integer.str
Author unknown
Since unknown

This module contains a collection of strategies for working withlists of integers.




Statistics


General
Lines of code 396
Stratego
Module number 1 (100% documented)
Constructor number 1 (0% documented)
Overlay number 0
Strategy number 80 (48% documented)
Rule number 6 (0% documented)
DynamicRule number 1 (0% documented)



Strategy summary


add-lists Adds together multiple lists of numbers integer.str
average Returns the average of all integers in a list of integers integer.str
int-sort n/a integer.str
is-interval-from n/a integer.str
list-accum(Strategy s) Reduces a list, applying s successively between the head and tail of the list integer.str
list-max Returns the highest integer in a list of integers integer.str
list-min Returns the lowest integer in a list of integers integer.str
range Generates range of numbers in the form of an integer list integer.str
range Generates a range of numbers in the form of an integer list integer.str
range(ATerm step) Generates a sequence of integers, using a specified step size integer.str
range(ATerm step) Generates a sequence of integers, using a specified step size integer.str
range(Strategy next) Generates a sequence of numbers using a generator strategy integer.str
range(Strategy next) n/a integer.str
sum Returns the sum of all integers in a list of integers integer.str

Rule summary


is-interval Succeeds if the input term is a list of monotonously increasing integers and the difference between two adjacent integers is always one integer.str



Strategy details


ATerm add-lists
File integer.str
Author unknown
Since unknown
 

Adds together multiple lists of numbers. The inputis a list of integer (or real) lists, which all mustbe of the same length. The result is one list ofthe same length, i.e. a sum of vectors.

Example: <add-lists> [[1.0,2.0],[3,4],[6,7]] => [1.000000000000000e+01,1.300000000000000e+01]


type List(List(Number)) -> List(Number)

 
ATerm average
File integer.str
Author unknown
Since unknown
 

Returns the average of all integers in a list ofintegers. The result is an integer, which is truncated (rounded down).


type List(Int) -> Int

 
ATerm list-accum(Strategy s)
File integer.str
Author unknown
Since unknown
 
Parameters
Strategy s (a,b) -> c

Reduces a list, applying s successively betweenthe head and tail of the list. This strategy isrelated to foldl.

Example: <list-accum(id)> [1,2,3] => (3,(2,1))


type List(a) -> d

 
ATerm list-max
File integer.str
Author unknown
Since unknown
 

Returns the highest integer in a list of integers.


type List(Int) -> Int

 
ATerm list-min
File integer.str
Author unknown
Since unknown
 

Returns the lowest integer in a list of integers.


type List(Int) -> Int

 
ATerm range
File integer.str
Author unknown
Since 0.9.3
 

Generates range of numbers in the form of an integer list. This version of range accepts only one integer as input. The generatedsequence of integers is generated, starts at 0 and increases by oneuntil the specified end point is reached. The end point is neverpart of the generated list.

Example: <range> 10 => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]


type Int -> List(Int)
type Int * Int -> List(Int)

 
ATerm range
File integer.str
Author unknown
Since 0.9.3
 

Generates a range of numbers in the form of an integer list. This versionof range accepts two integers as input. The first is the lower bound, ofthe sequence, the second is the upper bound. The upper bound is neverpart of the generated list.

Example: <range> (5, 10) => [5, 6, 7, 8, 9]


type Int * Int -> List(Int)

 
ATerm range(ATerm step)
File integer.str
Author unknown
Since 0.9.3
 

Generates a sequence of integers, using a specified step size. This versionof range starts at zero and adds one integer to the sequence for everystep specified by the term argument. The input term gives the upper boundof the sequence, and is never included. The step size is allowedto be negative.

Example: <range(|3)> 10 => [0, 3, 6, 9]Example: <range(|-30)> (-10, -100) => [-10, -40, -70]


type step Int
type Int -> List(Int)
type Int * Int -> List(Int)

 
ATerm range(ATerm step)
File integer.str
Author unknown
Since 0.9.3
 

Generates a sequence of integers, using a specified step size. This versionof range starts at zero and adds one integer to the sequence for everystep specified by the term argument. The input terms give the lower andupper bound of the sequence, respectively. The upper bound is neverincluded. The step size is allowed to be negative.

Example: <range(|3)> (0, 10) => [0, 3, 6, 9]


type step Int
type Int -> List(Int)
type Int * Int -> List(Int)

 
ATerm range(Strategy next)
File integer.str
Author unknown
Since unknown
 

Generates a sequence of numbers using a generator strategy. Theinput integer is the upper bound. The strategy argument is a generator which specifies how to go from the current number inthe sequence to the next. The sequence starts at 0.

Example: <range(inc)> 5 => [0,1,2,3,4]


type next Int -> Int
type Int -> List(Int)

 
ATerm sum
File integer.str
Author unknown
Since unknown
 

Returns the sum of all integers in a list of integers


type List(Int) -> Int

 

Rule details


ATerm is-interval
File integer.str
Author unknown
Since unknown
 

Succeeds if the input term is a list of monotonously increasingintegers and the difference between two adjacent integers isalways one.

Example: <is-interval> [1,2,3,4,5] => (1,5)


type List(Int) -> _