diff options
-rw-r--r-- | software/haskell.page | 27 | ||||
-rw-r--r-- | software/unix-tricks.page | 9 |
2 files changed, 36 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 ------------ diff --git a/software/unix-tricks.page b/software/unix-tricks.page index 533a174..41bda41 100644 --- a/software/unix-tricks.page +++ b/software/unix-tricks.page @@ -16,3 +16,12 @@ To fork off 10 instances of sleep with incremented lengths, 5 at a time:: $ seq 10 20 | xargs -n 1 -P 5 sleep +Remapping a Keyboard Key to Meta +----------------------------------- +I like having a Meta key (aka "Windows key") for use with system keyboard +shortcuts (change desktop etc), but some laptop keyboards don't have an extra +button. To remap one of the Alt keys, you need to know it's code: on FreeBSD +6.3 it was: ``Alt_R keysum 0xffea keycode 113``. To get the right mapping under +X11, read the directions in ``/usr/X11R6/lib/X11/xkb/README``. To get the right +mapping under the console, edit ``/usr/share/syscons/keymaps/us.iso.kbd`` and +change 'ralt' to 'meta'. |