summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorven <vendethiel@hotmail.fr>2015-02-02 21:44:00 +0100
committerven <vendethiel@hotmail.fr>2015-02-02 21:44:00 +0100
commit8208aad86210c51cee729fc79842aabf854b018c (patch)
tree2cd92b736e0c08423d57b3ea516e3a119c239c96
parentf41adf85e01e5af6579d81cda5759e156298dd12 (diff)
parent5f4b9d5ba4807693f955ba6a6c71ecc39ab19b42 (diff)
Merge pull request #951 from devinmcginty/master
Add more information on ranges in Haskell
-rw-r--r--haskell.html.markdown11
1 files changed, 10 insertions, 1 deletions
diff --git a/haskell.html.markdown b/haskell.html.markdown
index 748a29da..52433aaa 100644
--- a/haskell.html.markdown
+++ b/haskell.html.markdown
@@ -59,6 +59,7 @@ not False -- True
"Hello " ++ "world!" -- "Hello world!"
-- A string is a list of characters
+['H', 'e', 'l', 'l', 'o'] -- "Hello"
"This is a string" !! 0 -- 'T'
@@ -67,10 +68,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