diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-01-26 14:25:22 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-01-26 14:25:22 -0800 |
commit | ef2f7205bc38429b41bcb3b33db7ea2ca464e0c3 (patch) | |
tree | 95fe4bd83bbb5f97e75be2f2614ef3861e7fe0cc /txr.1 | |
parent | a2b16d316cf9201fa27d35766f5f245c2c9a6b26 (diff) | |
download | txr-ef2f7205bc38429b41bcb3b33db7ea2ca464e0c3.tar.gz txr-ef2f7205bc38429b41bcb3b33db7ea2ca464e0c3.tar.bz2 txr-ef2f7205bc38429b41bcb3b33db7ea2ca464e0c3.zip |
* txr.1: More discussion of ranges.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -4886,6 +4886,7 @@ Retrieve the specified range of elements, exactly as if using (sub-list <list> <from-index> <to-below-index>). The range of elements is specified in the car and cdr fields of a cons cell, for which the .. (dotdot) syntactic sugar is useful. +See the section on Indexing below. .IP [<vector> <index>] Retrieve the specified element of a vector. This is equivalent to @@ -4896,6 +4897,7 @@ Retrieve the specified range of elements, exactly as if using (sub-vec <list> <from-index> <to-below-index>). The range of elements is specified in the car and cdr fields of a cons cell, for which the .. (dotdot) syntactic sugar is useful. +See the section on Range Indexing below. .IP [<string> <index>] Retrieve the specified element of a string. This is equivalent to @@ -4915,6 +4917,26 @@ range updates the form which contains the list, so the expression denoting the list must be an assignable place. .TP +Range Indexing + +Array and list range indexing is based from zero. The first element element +zero. Furthermore, the value -1 refers to the last element of the array or +list, and -2 to the second last and so forth. So the range 1 .. -2 means +"everything except for the first element and the last two". + +The symbol t represents the position one past the end of the array or +list, so 0 .. t denotes the entire list or array, and the range t .. t +represents the empty range just beyond the last element. +It is possible to assign to t .. t. For instance: + + (defvar list '(1 2 3)) + (set [list t .. t] '(4)) ;; list is now (1 2 3 4) + +Either end of the range can also be specified as nil. If the start is specified +as nil, it means zero. If the end is specified as nil, it means one element +past the end. Thus nil .. nil spans all of the elements. + +.TP Notes: The dwim operator allows for a Lisp-1 flavor of programming in TXR Lisp, |