APIRange
Range
Numeric ranges traversed without building a list.
List.range builds the values of a range as a list; Range.each visits
them one at a time instead.
each
each : (Num a, Ord a) => (a ->{e} ()) -> a -> a ->{e} ()Source
Calls action with every value from start through end inclusive,
counting up by one, in ascending order. It does nothing when start is
greater than end. The callback’s effects are the call’s, and it works at
both Int and Float; the bounds must be finite, since traversal is not
guaranteed to end for NaN or an infinity.
import Range
import State
total = State.run 0 { Range.each { n -> State.put (State.get () + n) } 1 4 }
total.state == 10
