Skip to content

Commit

Permalink
Add more information on ranges in Haskell
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmcginty committed Feb 1, 2015
1 parent 177adaa commit 5f45319
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion haskell.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,18 @@ not False -- True
----------------------------------------------------

-- Every element in a list must have the same type.
-- Two lists that are the same
-- These two lists are the same
[1, 2, 3, 4, 5]
[1..5]

-- Ranges are versatile.
['A'..'F'] -- "ABCDEF"

-- You can create a step in a range.
[0,2..10] -- [0, 2, 4, 6, 8, 10]
[5..1] -- This doesn't work because Haskell defaults to incrementing.
[5,4..1] -- [5, 4, 3, 2, 1]

-- You can also have infinite lists in Haskell!
[1..] -- a list of all the natural numbers

Expand Down

0 comments on commit 5f45319

Please sign in to comment.