This module contains a collection of strategies for working withlists of integers.
Strategy details
|
ATerm
|
add-lists
|
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
|
Returns the average of all integers in a list ofintegers. The result is an integer, which is truncated (rounded down).
|
|
ATerm
|
list-accum(Strategy s)
|
File
|
integer.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
|
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))
|
|
ATerm
|
list-max
|
Returns the highest integer in a list of integers.
|
|
ATerm
|
list-min
|
Returns the lowest integer in a list of integers.
|
|
ATerm
|
range
|
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
|
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)
|
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)
|
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)
|
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
|
Returns the sum of all integers in a list of integers
|
|