This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Iterates consecutive range of int numbers avoiding consuming extra memory.
version 2.0.0
license BSD3
native-modules True
elm-version 0.15.0 <= v < 0.16.0
Tag 2.0.0
Committed At 2015-07-12 14:14:37 UTC
elm-lang/core 2.0.0 <= v < 3.0.0 2.1.0

Modules

README

IntRange

The library provides fold/map* functions for the range of Int numbers avoiding consuming extra memory.

IntRange.foldl/foldr/map/map2 can be used replacement of List Int value which represents certain range of Int values.

This is useful when iterate vast numbers avoiding consuming extra memory.

For example,

      import IntRange (to)
      import IntRange
      Import List

      IntRange.foldl (+) 0 (0 `to` 100000000) -- Can be calculate without consuming extra memory.
      List.foldl (+) 0 [0..100000000] -- Requires memory for the List of Int which length is 100000000.

Both of List.foldl and IntRange.foldl don't consumes call stack, but List.foldl version consumes memory for the list [0..100000000], in the contrast of IntRange.fold requres relatively small constant memory.

You can create range and invert range by functions to and downTo respectedly:

       IntRange.map (\a->a+1) (1 `to` 3) -- [2,3,4]
       IntRange.map (\a->a+1) (3 `downTo` 1) -- [4,3,2]