version | 1.0.0 |
license | BSD3 |
native-modules | False |
elm-version | 0.18.0 <= v < 0.19.0 |
Tag | 1.0.0 |
Committed At | 2017-07-01 19:48:33 UTC |
This library provides a way of putting of computations until they are needed, allowing for expensive calculations later.
lazySum : Lazy Int
lazySum =
lazy (\() -> sum <| List.range 1 1000000)
It also gives you a way of storing a computed value so that you do not need to re-compute it.
lazySum : Int -> Lazy Int
lazySum n =
lazy (\() -> sum <| List.range 0 n)
lazySums : List Int -> List (Lazy Int)
lazySums sums =
List.map lazySum sums
-- evaluates the head, before putting it back on the list
evaluteCurrentSum : List (Lazy Int) -> List (Lazy Int)
evaluteCurrentSum xs =
case xs of
head::rest -> Lazy.evaluate head :: rest
_ -> []
This is a library based originally on the old Lazy
implementation. However, it is written entirely in pure Elm. The main difference is explicit memoization, as we no longer use side-effects to achieve laziness.