From 7cf7504c7baa1270fb85c3b03e58f0ede82daea1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 25 Dec 2011 21:30:08 -0800 Subject: More formatting changes. --- txr.1 | 459 ++++++++++++++++++++++++++++-------------------------------------- 1 file changed, 192 insertions(+), 267 deletions(-) diff --git a/txr.1 b/txr.1 index 36fdf3ac..2bb42280 100644 --- a/txr.1 +++ b/txr.1 @@ -4343,7 +4343,7 @@ indicated as bar-separated items. .TP Syntax: -(progn
*) + (progn *) .TP Description @@ -4360,10 +4360,8 @@ These operators are said to feature an "implicit progn". .TP Syntax: -.nf -(let ({ | ( )}*) *) -(let* ({ | ( )}*) *) -.fi + (let ({ | ( )}*) *) + (let* ({ | ( )}*) *) .TP Description: @@ -4396,19 +4394,17 @@ The variable list may be empty. .TP Examples: -.nf -(let ((a 1) (b 2)) (list a b)) -> (1 2) -(let* ((a 1) (b (+ a 1))) (list a b (+ a b))) -> (1 2 3) -(let ()) -> nil -(let (:a nil)) -> error, :a and nil can't be used as variables -.fi + (let ((a 1) (b 2)) (list a b)) -> (1 2) + (let* ((a 1) (b (+ a 1))) (list a b (+ a b))) -> (1 2 3) + (let ()) -> nil + (let (:a nil)) -> error, :a and nil can't be used as variables .SS Operator lambda .TP Syntax: -(lambda ({}*[. ]) {}*) + (lambda ({}*[. ]) {}*) .TP Description: @@ -4442,24 +4438,20 @@ Counting function. This function, which takes no arguments, captures the variable "counter". Whenever this object is called, it increments the counter by 1 and returns the incremented value. -.nf -(let ((counter 0)) - (lambda () (inc counter))) -.fi + (let ((counter 0)) + (lambda () (inc counter))) Function that takes two or more arguments. The third and subsequent arguments are aggregated into a list passed as the single parameter z: -.nf -(lambda (x y . z) (list 'my-arguments-are x y z)) -.fi + (lambda (x y . z) (list 'my-arguments-are x y z)) .SS Operator call .TP Syntax: -(call {}*) + (call {}*) .TP Description: @@ -4491,7 +4483,7 @@ Useless use of call on a named function; equivalent to (list 1 2): .TP Syntax: -(fun ) + (fun ) .TP Description: @@ -4510,7 +4502,7 @@ syntax (fun (lambda ...)) is invalid. .TP Syntax: -(cond {( {form}*)}*) + (cond {( {form}*)}*) .TP Description: @@ -4535,7 +4527,7 @@ nil. This holds in the case that the syntax is empty: (cond) yields nil. .TP Syntax: -(if []) + (if []) .TP Description: @@ -4552,7 +4544,7 @@ as if were specified as nil. .TP Syntax: -(and {}*) + (and {}*) .TP Description: @@ -4572,18 +4564,16 @@ the return value. .TP Examples: -.nf -(and) -> t -(and (> 10 5) (stringp "foo")) -> t -(and 1 2 3) -> 3 -.fi + (and) -> t + (and (> 10 5) (stringp "foo")) -> t + (and 1 2 3) -> 3 .SS Operator or .TP Syntax: -(or {}*) + (or {}*) .TP Description: @@ -4603,19 +4593,17 @@ operator yields the return value. .TP Examples: -.nf -(or) -> nil -(or 1 2) -> 1 -(or nil 2) -> 2 -(or (> 10 20) (stringp "foo")) -> t -.fi + (or) -> nil + (or 1 2) -> 1 + (or nil 2) -> 2 + (or (> 10 20) (stringp "foo")) -> t .SS Operator defun .TP Syntax: -(defun ({ [. ]}*) *) + (defun ({ [. ]}*) *) Description: @@ -4633,14 +4621,12 @@ A function may call itself by name, allowing for recursion. .TP Syntax: -.nf -(inc []) -(dec []) -(set ) -(push ) -(pop ) -(flip ) -.fi + (inc []) + (dec []) + (set ) + (push ) + (pop ) + (flip ) .TP Description: @@ -4726,12 +4712,10 @@ to be treated as assignment places. .TP Syntax: -.nf -({for | for*} ({ | ( )}*) - ( *) - (*) - *) -.fi + ({for | for*} ({ | ( )}*) + ( *) + (*) + *) .TP Description: @@ -4767,10 +4751,8 @@ allowing the return operator to be used to terminate at any point. .TP Syntax: -.nf -(dohash ( []) - *) -.fi + (dohash ( []) + *) .TP Description: @@ -4798,7 +4780,7 @@ dohash early using (return) or (return ). .TP Syntax: -(unwind-protect *) + (unwind-protect *) .TP Description: @@ -4819,13 +4801,11 @@ is aborted and replaced with the new one. .TP Example: -.nf - (block foo - (unwind-protect - (progn (return-from foo 42) - (format t "not reached!\en")) - (format t "cleanup!\n"))) -.fi + (block foo + (unwind-protect + (progn (return-from foo 42) + (format t "not reached!\en")) + (format t "cleanup!\n"))) In this example, the protected progn form terminates by returning from block foo. Therefore the form does not complete and so the @@ -4838,7 +4818,7 @@ excecutes, producing the output "cleanup!". .TP Syntax: -(block *} + (block *} .TP Description: @@ -4884,10 +4864,8 @@ the construct. THROW itself is a function and not an operator. .TP Syntax: -.nf -(return []) -(return-from []) -.fi + (return []) + (return-from []) .TP Description: @@ -4906,14 +4884,12 @@ value. If the value is omitted, that block returns nil. .TP Example: -.nf - (block foo - (let ((a "abc\n") - (b "def\n")) - (pprint a *stdout*) - (return-from foo 42) - (pprint b *stdout*))) -.fi + (block foo + (let ((a "abc\n") + (b "def\n")) + (pprint a *stdout*) + (return-from foo 42) + (pprint b *stdout*))) Here, the output produced is "abc". The value of b is not printed because the return-from terminates block foo, and so the second pprint @@ -4936,7 +4912,7 @@ The following are Lisp functions and variables built-in to TXR. .TP Syntax: -(identity ) + (identity ) .TP Description: @@ -4949,7 +4925,7 @@ The identity function returns its argument. .TP Syntax: -(typeof ) + (typeof ) .TP Description @@ -5020,7 +4996,7 @@ There are additional kinds of objects, such as streams. .TP Syntax: -(cons ) + (cons ) .TP @@ -5054,10 +5030,8 @@ The list (1 2) is (1 . (2 . nil)). .TP Syntax: -.nf -(car ) -(first ) -.fi + (car ) + (first ) .TP Description: @@ -5073,10 +5047,8 @@ even though nil isn't a cons and doesn't have a "car" field. .TP Syntax: -.nf -(cdr ) -(rest ) -.fi + (cdr ) + (rest ) .TP Description: @@ -5092,11 +5064,9 @@ Example: Walk every element of the list (1 2 3): -.nf - (for ((i '(1 2 3))) (i) ((set i (cdr i))) - (print (car i) *stdout*) - (print #\newline *stdout*)) -.fi + (for ((i '(1 2 3))) (i) ((set i (cdr i))) + (print (car i) *stdout*) + (print #\newline *stdout*)) The variable i marches over the cons cells which make up the "backbone" of the list. The elements are retrieved using the car function. @@ -5109,10 +5079,8 @@ expression i fails and the loop terminates. .TP Syntax: -.nf -(rplaca ) -(rplacd ) -.fi + (rplaca ) + (rplacd ) .TP Description: @@ -5130,14 +5098,12 @@ whereas (car nil) is correct, (rplaca nil ...) is erroneous. .TP Syntax: -.nf -(first ) -(second ) -(third ) -(fourth ) -(fifth ) -(sixth ) -.fi + (first ) + (second ) + (third ) + (fourth ) + (fifth ) + (sixth ) .TP Description: @@ -5149,11 +5115,9 @@ If the list is shorter than implied, these functions return nil. .TP Examples: -.nf -(third '(1 2)) -> nil -(second '(1 2)) -> 2 -(third '(1 2 . 3)) -> **error** -.fi + (third '(1 2)) -> nil + (second '(1 2)) -> 2 + (third '(1 2 . 3)) -> **error** .SS Function append @@ -5182,36 +5146,34 @@ be an atom other than nil; in that case append produces an improper list. .TP Examples: -.nf -;; An atom is returned. -(append 3) -> 3 + ;; An atom is returned. + (append 3) -> 3 -;; A list is also just returned: no copying takes place. -;; The eq function can verify that the same object emerges -;; from append that went in. -(let ((list '(1 2 3))) - (eq (append list) list)) -> t + ;; A list is also just returned: no copying takes place. + ;; The eq function can verify that the same object emerges + ;; from append that went in. + (let ((list '(1 2 3))) + (eq (append list) list)) -> t -(append '(1 2 3) '(4 5 6) 7) -> '(1 2 3 4 5 6 . 7)) + (append '(1 2 3) '(4 5 6) 7) -> '(1 2 3 4 5 6 . 7)) -;; the (4 5 6) tail of the resulting list is the original -;; (4 5 6) object, shared with that list. + ;; the (4 5 6) tail of the resulting list is the original + ;; (4 5 6) object, shared with that list. -(append '(1 2 3) '(4 5 6)) -> '(1 2 3 4 5 6) + (append '(1 2 3) '(4 5 6)) -> '(1 2 3 4 5 6) -(append nil) -> nil + (append nil) -> nil -;; (1 2 3) is copied: it is not the last argument -(append '(1 2 3) nil) -> (1 2 3) + ;; (1 2 3) is copied: it is not the last argument + (append '(1 2 3) nil) -> (1 2 3) -;; empty lists disappear -(append nil '(1 2 3) nil '(4 5 6)) -> (1 2 3 4 5 6) -(append nil nil nil) -> nil + ;; empty lists disappear + (append nil '(1 2 3) nil '(4 5 6)) -> (1 2 3 4 5 6) + (append nil nil nil) -> nil -;; atoms and improper lists other than in the last position -;; are erroneous -(append '(a . b) 3 '(1 2 3)) -> **error** -.fi + ;; atoms and improper lists other than in the last position + ;; are erroneous + (append '(a . b) 3 '(1 2 3)) -> **error** .SS Function list @@ -5229,11 +5191,9 @@ argument values. .TP Examples: -.nf -(list) -> nil -(list 1) -> (1) -(list 'a 'b) -> (a b) -.fi + (list) -> nil + (list 1) -> (1) + (list 'a 'b) -> (a b) .SS Function atom @@ -5252,22 +5212,18 @@ case, nil otherwise. All values which are not cons cells are atoms. .TP Examples: -.nf -(atom 3) -> t -(atom (cons 1 2)) -> nil -(atom "abc") -> t -(atom '(3)) -> nil -.fi + (atom 3) -> t + (atom (cons 1 2)) -> nil + (atom "abc") -> t + (atom '(3)) -> nil .SS Functions null and not .TP Syntax: -.nf -(null ) -(not ) -.fi + (null ) + (not ) .TP Description: @@ -5278,17 +5234,15 @@ object nil. They returns t if this is the case, nil otherwise. .TP Examples: -.nf -(null '()) -> t -(null nil) -> t -(null ()) -> t + (null '()) -> t + (null nil) -> t + (null ()) -> t -(if (null x) (format t "x is nil!")) + (if (null x) (format t "x is nil!")) -(let ((list '(b c d))) - (if (not (memq 'a list)) - (format t "list ~s does not contain the symbol a\en"))) -.fi + (let ((list '(b c d))) + (if (not (memq 'a list)) + (format t "list ~s does not contain the symbol a\en"))) .SS Function consp @@ -5311,12 +5265,10 @@ as a reference to the first cons in a chain of one or more conses. .TP Examples: -.nf -(consp 3) -> nil -(consp (cons 1 2)) -> t -(consp "abc") -> nil -(consp '(3)) -> t -.fi + (consp 3) -> nil + (consp (cons 1 2)) -> t + (consp "abc") -> nil + (consp '(3)) -> t .SS Function make_lazy_cons @@ -5351,29 +5303,27 @@ and install the resulting cons as the cdr of the lazy cons. .TP Example: -.nf -;;; lazy list of integers between min and max -(defun integer-range (min max) - (let ((counter min)) - ;; min is greater than max; just return empty list, - ;; otherwise return a lazy list - (if (> min max) - nil - (make-lazy-cons (lambda (lcons) - ;; install next number into car - (rplaca lcons counter) - ;; now deal wit cdr field - (cond - ;; max reached, terminate list with nil! - ((eql counter max) - (rplacd lcons nil)) - ;; max not reached: increment counter - ;; and extend with another lazy cons - (t - (inc counter) - (rplacd lcons (make-lazy-cons - (lcons-fun lcons)))))))))) -.fi + ;;; lazy list of integers between min and max + (defun integer-range (min max) + (let ((counter min)) + ;; min is greater than max; just return empty list, + ;; otherwise return a lazy list + (if (> min max) + nil + (make-lazy-cons (lambda (lcons) + ;; install next number into car + (rplaca lcons counter) + ;; now deal wit cdr field + (cond + ;; max reached, terminate list with nil! + ((eql counter max) + (rplacd lcons nil)) + ;; max not reached: increment counter + ;; and extend with another lazy cons + (t + (inc counter) + (rplacd lcons (make-lazy-cons + (lcons-fun lcons)))))))))) .SS Function lcons-fun @@ -5397,10 +5347,8 @@ another lazy cons (as in the example under make-lazy-cons). .TP Syntax: -.nf -(listp ) -(proper-listp ) -.fi + (listp ) + (proper-listp ) .TP Description: @@ -5433,10 +5381,8 @@ list. The length of a list is the number of conses in that list. .TP Syntax: -.nf -(mapcar *) -(mappend *) -.fi + (mapcar *) + (mappend *) .TP When given three arguments, the mapcar function processes applies a function to @@ -5462,21 +5408,19 @@ That is to say, (mappend f a b c) is equivalent to .TP Examples: -.nf -;; multiply every element by two -(mapcar (lambda (item) (* 2 item)) '(1 2 3)) -> (4 6 8) + ;; multiply every element by two + (mapcar (lambda (item) (* 2 item)) '(1 2 3)) -> (4 6 8) -;; "zipper" two lists together -(mapcar (lambda (le ri) (list le ri)) '(1 2 3) '(a b c)) '((1 a) (2 b) (3 c))) + ;; "zipper" two lists together + (mapcar (lambda (le ri) (list le ri)) '(1 2 3) '(a b c)) '((1 a) (2 b) (3 c))) -;; like append, mappend allows a lone atom or a trailing atom: -(mappend (fun identity) 3) -> (3) -(mappend (fun identity) '((1) 2)) -> (1 . 2) + ;; like append, mappend allows a lone atom or a trailing atom: + (mappend (fun identity) 3) -> (3) + (mappend (fun identity) '((1) 2)) -> (1 . 2) -;; take just the even numbers -(mappend (lambda (item) (if (evenp x) (list x))) '(1 2 3 4 5)) --> (2 4) -.nf + ;; take just the even numbers + (mappend (lambda (item) (if (evenp x) (list x))) '(1 2 3 4 5)) + -> (2 4) .SS Function apply @@ -5495,10 +5439,8 @@ value becomes the return value of apply. .TP Examples: -.nf -;; '(1 2 3) becomes arguments to list, thus (list 1 2 3). -(apply (fun list) '(1 2 3)) -> (1 2 3) -.fi + ;; '(1 2 3) becomes arguments to list, thus (list 1 2 3). + (apply (fun list) '(1 2 3)) -> (1 2 3) .TP Dialect note: @@ -5514,10 +5456,8 @@ yields (1 2 3 4 5). In TXR Lisp, this usage can be simulated using .TP Syntax: -.nf -(reduce-left ) -(reduce-right ) -.fi + (reduce-left ) + (reduce-right ) .TP Description: @@ -5551,26 +5491,24 @@ to an argument to . The value nil is equivalent to .TP Examples: -.nf -;;; list is empty, so 1 is just returned: -(reduce-left (fun +) () 1 nil) -> 1 + ;;; list is empty, so 1 is just returned: + (reduce-left (fun +) () 1 nil) -> 1 -;;; computes (- (- (- 0 1) 2) 3) -(reduce-left (fun -) '(1 2 3) 0 nil) -> -6 + ;;; computes (- (- (- 0 1) 2) 3) + (reduce-left (fun -) '(1 2 3) 0 nil) -> -6 -;;; computes (- 1 (- 2 (- 3 0))) -(reduce-right (fun -) '(1 2 3) 0 nil) -> 2 + ;;; computes (- 1 (- 2 (- 3 0))) + (reduce-right (fun -) '(1 2 3) 0 nil) -> 2 -;;; computes (* 1 2 3) -(reduce-left (fun *) '((1) (2) (3)) 1 (fun first)) -> 6 -.fi + ;;; computes (* 1 2 3) + (reduce-left (fun *) '((1) (2) (3)) 1 (fun first)) -> 6 .SS Function copy-list .TP Syntax: -(copy-list ) + (copy-list ) .TP Description: @@ -5595,10 +5533,8 @@ for the empty list nil. .TP Syntax: -.nf -(reverse ) -(nreverse ) -.fi + (reverse ) + (nreverse ) .TP Description: @@ -5621,7 +5557,7 @@ reverse order. Other approaches are possible. .TP Syntax: -(ldiff ) + (ldiff ) .TP Description: @@ -5644,23 +5580,22 @@ then a copy of is returned. .TP Examples: -.nf -;;; unspecified: the compiler could make '(2 3) a suffix of '(1 2 3), -;;; or they could be separate objects. -(ldiff '(1 2 3) '(2 3)) -> either (1) or (1 2 3) + ;;; unspecified: the compiler could make '(2 3) a suffix of '(1 2 3), + ;;; or they could be separate objects. + (ldiff '(1 2 3) '(2 3)) -> either (1) or (1 2 3) -;; b is the (1 2) suffix of a, so the ldiff is (1) -(let ((a '(1 2 3)) (b (cdr a))) - (ldiff a b)) --> (1) -.fi + ;; b is the (1 2) suffix of a, so the ldiff is (1) + (let ((a '(1 2 3)) (b (cdr a))) + (ldiff a b)) + -> (1) .SS Functions flatten, lazy-flatten .TP Syntax: -(flatten ) + (flatten ) + (lazy-flatten ) .TP Description: @@ -5675,27 +5610,23 @@ structure is itself lazy. .TP Examples: -.nf -(flatten '(1 2 () (3 4))) -> (1 2 3 4) + (flatten '(1 2 () (3 4))) -> (1 2 3 4) -;; precisely equivalent to previous example! nil is the same thing as () -(flatten '(1 2 nil (3 4))) -> (1 2 3 4) + ;; precisely equivalent to previous example! nil is the same thing as () + (flatten '(1 2 nil (3 4))) -> (1 2 3 4) -(flatten nil) -> nil + (flatten nil) -> nil -(flatten '(((()) ()))) -> nil -.fi + (flatten '(((()) ()))) -> nil .SS Functions memq, memql and memqual .TP Syntax: -.nf -(memq ) -(memql ) -(memqual ) -.fi + (memq ) + (memql ) + (memqual ) .TP Description: @@ -5714,7 +5645,7 @@ is the matching object. .TP Syntax: -(tree-find ) + (tree-find ) .TP Description: @@ -5739,11 +5670,9 @@ which returns non-nil. .TP Syntax: -.nf -(some ) -(all ) -(none ) -.fi + (some ) + (all ) + (none ) .TP Description @@ -5782,24 +5711,20 @@ values, the none function returns t. .TP Examples: -.nf -;; some of the integers are odd -(some (fun oddp) '(2 4 6 9) nil) -> t + ;; some of the integers are odd + (some (fun oddp) '(2 4 6 9) nil) -> t -;; none of the integers are even -(none (fun evenp) '(1 3 4 7) nil) -> t -.fi + ;; none of the integers are even + (none (fun evenp) '(1 3 4 7) nil) -> t .SS Functions eq, eql and equal .TP Syntax: -.nf -(eq ) -(eql ) -(equal ) -.fi + (eq ) + (eql ) + (equal ) .TP Description: -- cgit v1.2.3