Package

purescript-infinite-list

Repository
robertmassaioli/purescript-infinite-list
License
MIT
Uploaded by
robertmassaioli

Build Status

This language allows you to have infinite lists that are:

You can do this with an easy to understand interface that guarantees infinite lists.

For example, to create an infinite list of the natural numbers:

naturals = iterate ((+) 1) 1

Then, to get only the elements that are divisible by three or five, you could write:

byThreeOrFive = filter (\x -> (x `mod` 3 == 0) || (x `mod` 5 == 0)) naturals

You can then multiply every number in that list by two:

byThreeOrFiveDoubled = map (\x -> x * 2) byThreeOrFive

Running this through psci you then get the following results:

> take 10 byThreeOrFiveDoubled
(6 : 10 : 12 : 18 : 20 : 24 : 30 : 36 : 40 : 42 : Nil)

>

You can use the methods provided by this library to create many different kinds of infinite lists. Please read the documentation further to learn how to further generate and manipulate infinite lists.