8.0
algorithms
A package containing many useful algorithms (borrowed from many other programming languages).
Returns a list of elements after apply proc to adjacent elements.
This algorithm is similar to Haskell’s mapAdjacent.
Returns #t if all the elements of lst are #t, otherwise returns #f.
This algorithm is similar to Python’s all.
Returns #t if any of the elements of lst are #t, otherwise returns #f.
This algorithm is similar to Python’s any.
Returns a list of lists of k elements each. Note that this is a specialization of sliding where size is equal to step.
This algorithms is the same as Haskell’s chunksOf.
Returns a list of n elements generated from invoking proc n times.
This algorithm is similar to C++’s generate.
Returns #t if all the elements of lst are strictly increasing, otherwise returns #f.
Return all the elements of a list except the last one.
This algorithm comes from Haskell’s init.
(product lst) → Real
|
lst : (listof Real) |
Returns the product of the elements in lst.
Returns a list of val repeated n times.
This algorithms is the same as Clojures’s repeat and D’s repeat.
scanl is similar to
foldl, but returns a list of successive reduced values from the left.
This algorithm originally comes from APL’s monadic \ scan operator. It is more similar to Haskell’s scanl1 however.
scanr is similar to
foldr, but returns a list of successive reduced values from the right.
This algorithm originally comes from APL’s monadic \ scan operator. It is more similar to Haskell’s scanr1 however.
Returns a list of lists of size elements each, at offset step apart. Note that step is defaulted to 1.
This algorithms is the same as Haskell’s divvy, Clojure’s partition and D’s slide.
Returns #t if all the elements of lst are in sorted order, otherwise returns #f.
This algorithm is similar to C++’s std::is_sorted.
(sum lst) → Real
|
lst : (listof Real) |
Returns the sum of the elements in lst.
Return all the elements of a list except the first one.
Note: this is the same as Racket’s cdr and rest and therefore isn’t really necessary.
This algorithm comes from Haskell’s tail.
Returns a list of corresponding pairs when given two lists.
This algorithm is similar to Haskell’s zip.
Returns a list after zipping together the variadic number of lsts and applying proc to each of the "zipped together" elements.
This algorithm is similar to Haskell’s zipWith.