summaryrefslogtreecommitdiffstats
path: root/software/haskell.page
diff options
context:
space:
mode:
authorbryan newbold <bnewbold@robocracy.org>2010-02-16 13:49:22 -0500
committerbryan newbold <bnewbold@robocracy.org>2010-02-16 13:49:22 -0500
commit14fd1caae8924a0c9fba43337c6ed47b26ba61e6 (patch)
treecd6af9f39f367f25d992b1b6f44cd60b12ba6822 /software/haskell.page
parent5c8148df01fe38cb1e5bc05b9013712358661c35 (diff)
downloadknowledge-14fd1caae8924a0c9fba43337c6ed47b26ba61e6.tar.gz
knowledge-14fd1caae8924a0c9fba43337c6ed47b26ba61e6.zip
ralt to meta trick
Diffstat (limited to 'software/haskell.page')
-rw-r--r--software/haskell.page27
1 files changed, 27 insertions, 0 deletions
diff --git a/software/haskell.page b/software/haskell.page
index 6911315..8e7d9f8 100644
--- a/software/haskell.page
+++ b/software/haskell.page
@@ -21,6 +21,33 @@ lines indented to the same position as the first non-whitespace after the
stuff1
stuff2
+Lists
+--------
+Lists in haskell are homogenous: all elements must of the same type. They are
+linked lists, so cons-ing on the front is cheap and concatonating on the end
+can be expensive.
+
+Use ++ to concatonate two lists together:
+
+ ['a','b','c'] ++ ['d','e','f']
+
+Use : to cons (prepend) a single element:
+
+ 0:[1,2,3,4,5,6]
+
+Use !! to pull out an element by index (zero indexed):
+
+ ['c','a','t'] !! 1
+
+Strings are lists of characters: "baby" is equivalent to ['b','a','b','y'],
+which is equivalent to 'b':'a':'b':'y':[]. The empty set is [] and is distinct
+from [[]].
+
+A couple functions help; 'head' is like 'car' and gives the first element,
+'tail' is like 'cdr' and gives everything except the first element, 'last'
+gives the last non-empty element, and 'init' gives everything except the
+'last'. 'length' gives the number of elements, 'null' is a test to see if this
+is the empty list,
Compilation
------------