From 5f45319d577e1ef8a0d28f08fd37a7ed76433958 Mon Sep 17 00:00:00 2001 From: Devin McGinty Date: Sat, 31 Jan 2015 19:40:55 -0500 Subject: [PATCH] Add more information on ranges in Haskell --- haskell.html.markdown | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/haskell.html.markdown b/haskell.html.markdown index 748a29da79..d5dd5141c8 100644 --- a/haskell.html.markdown +++ b/haskell.html.markdown @@ -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