| Learn | Haskell - Lists - Ranges |
|---|
| Ranges Creating a list from 1 to 10 is simple using range notation: To specify a step, add a comma and the next element after the start element: Note that Haskell always takes the step as the arithmetic difference between terms, and that you cannot specify more than the first two elements and the upper bound: To generate a range in descending order, always specify the negative step: Because Haskell is non-strict, the elements of the list are evaluated only if they are needed, which allows us to use infinite lists. Be careful when using ranges with floating-point values, because it accepts spill-overs up to half-delta, to fend off rounding issues: Ranges work not just with numbers but with any type that implements For example, with Notice the space after |
Read Article
https://develop.horje.com/learn/1434/reference