From ef2f7205bc38429b41bcb3b33db7ea2ca464e0c3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 26 Jan 2012 14:25:22 -0800 Subject: * txr.1: More discussion of ranges. --- ChangeLog | 4 ++++ txr.1 | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ChangeLog b/ChangeLog index fc73e42d..783aa5a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012-01-26 Kaz Kylheku + + * txr.1: More discussion of ranges. + 2012-01-26 Kaz Kylheku * match.c (format_field): Removed useless use of cat_str (no longer diff --git a/txr.1 b/txr.1 index ff427fc8..2b015d60 100644 --- a/txr.1 +++ b/txr.1 @@ -4886,6 +4886,7 @@ Retrieve the specified range of elements, exactly as if using (sub-list ). 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 [ ] 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 ). 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 [ ] Retrieve the specified element of a string. This is equivalent to @@ -4914,6 +4916,26 @@ the vector object; it is implemented using replace-vec. Assigning to a list 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: -- cgit v1.2.3