From 03748d885a22b40f2e1fa0922b1f8341da5c6656 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sun, 31 Jan 2021 15:51:09 +0000 Subject: [PATCH] Prefer '() over () in printed examples * dev/examples.el (-take, -drop, -drop-last, -take-while) (-running-sum, -running-product, -common-prefix, -common-suffix) (-list, -each-indexed, -dotimes): Prefer '() over () in printed examples, as we can control how the former is printed, whereas the latter is always printed as nil. * README.md: * dash.texi: Regenerate docs. --- README.md | 22 +++++++++++----------- dash.texi | 26 +++++++++++++------------- dev/examples.el | 22 +++++++++++----------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index e8f4834..2a33198 100644 --- a/README.md +++ b/README.md @@ -616,7 +616,7 @@ See also: [`-take-last`](#-take-last-n-list). ```el (-take 3 '(1 2 3 4 5)) ;; => '(1 2 3) (-take 17 '(1 2 3 4 5)) ;; => '(1 2 3 4 5) -(-take 0 '(1 2 3 4 5)) ;; => nil +(-take 0 '(1 2 3 4 5)) ;; => '() ``` #### -take-last `(n list)` @@ -643,7 +643,7 @@ For another variant, see also [`-drop-last`](#-drop-last-n-list). ```el (-drop 3 '(1 2 3 4 5)) ;; => '(4 5) -(-drop 17 '(1 2 3 4 5)) ;; => nil +(-drop 17 '(1 2 3 4 5)) ;; => '() (-drop 0 '(1 2 3 4 5)) ;; => '(1 2 3 4 5) ``` @@ -657,7 +657,7 @@ See also: [`-drop`](#-drop-n-list). ```el (-drop-last 3 '(1 2 3 4 5)) ;; => '(1 2) -(-drop-last 17 '(1 2 3 4 5)) ;; => nil +(-drop-last 17 '(1 2 3 4 5)) ;; => '() (-drop-last 0 '(1 2 3 4 5)) ;; => '(1 2 3 4 5) ``` @@ -673,7 +673,7 @@ This function's anaphoric counterpart is `--take-while`. For another variant, see also [`-drop-while`](#-drop-while-pred-list). ```el -(-take-while #'even? '(1 2 3 4)) ;; => nil +(-take-while #'even? '(1 2 3 4)) ;; => '() (-take-while #'even? '(2 4 5 6)) ;; => '(2 4) (--take-while (< it 4) '(1 2 3 4 3 2 1)) ;; => '(1 2 3) ``` @@ -1088,7 +1088,7 @@ Return a list with running sums of items in `list`. ```el (-running-sum '(1 2 3 4)) ;; => '(1 3 6 10) (-running-sum '(1)) ;; => '(1) -(-running-sum nil) ;; Error +(-running-sum '()) ;; Error ``` #### -product `(list)` @@ -1109,7 +1109,7 @@ Return a list with running products of items in `list`. ```el (-running-product '(1 2 3 4)) ;; => '(1 2 6 24) (-running-product '(1)) ;; => '(1) -(-running-product nil) ;; Error +(-running-product '()) ;; Error ``` #### -inits `(list)` @@ -1138,7 +1138,7 @@ Return the longest common prefix of `lists`. ```el (-common-prefix '(1)) ;; => '(1) -(-common-prefix '(1 2) '(3 4) '(1 2)) ;; => nil +(-common-prefix '(1 2) '(3 4) '(1 2)) ;; => '() (-common-prefix '(1 2) '(1 2 3) '(1 2 3 4)) ;; => '(1 2) ``` @@ -1148,7 +1148,7 @@ Return the longest common suffix of `lists`. ```el (-common-suffix '(1)) ;; => '(1) -(-common-suffix '(1 2) '(3 4) '(1 2)) ;; => nil +(-common-suffix '(1 2) '(3 4) '(1 2)) ;; => '() (-common-suffix '(1 2 3 4) '(2 3 4) '(3 4)) ;; => '(3 4) ``` @@ -2106,7 +2106,7 @@ backward compatibility and is otherwise deprecated. ```el (-list 1) ;; => '(1) -(-list nil) ;; => nil +(-list '()) ;; => '() (-list '(1 2 3)) ;; => '(1 2 3) ``` @@ -2692,7 +2692,7 @@ See also: [`-map-indexed`](#-map-indexed-fn-list). ```el (let (l) (-each-indexed '(a b c) (lambda (i x) (push (list x i) l))) l) ;; => '((c 2) (b 1) (a 0)) (let (l) (--each-indexed '(a b c) (push (list it it-index) l)) l) ;; => '((c 2) (b 1) (a 0)) -(let (l) (--each-indexed nil (push it l)) l) ;; => nil +(let (l) (--each-indexed '() (push it l)) l) ;; => '() ``` #### -each-r `(list fn)` @@ -2734,7 +2734,7 @@ This function's anaphoric counterpart is `--dotimes`. ```el (let (s) (-dotimes 3 (lambda (n) (push n s))) s) ;; => '(2 1 0) -(let (s) (-dotimes 0 (lambda (n) (push n s))) s) ;; => nil +(let (s) (-dotimes 0 (lambda (n) (push n s))) s) ;; => '() (let (s) (--dotimes 5 (push it s)) s) ;; => '(4 3 2 1 0) ``` diff --git a/dash.texi b/dash.texi index 1d42308..a61e2d9 100644 --- a/dash.texi +++ b/dash.texi @@ -673,7 +673,7 @@ See also: @code{-take-last} (@pxref{-take-last}). @end group @group (-take 0 '(1 2 3 4 5)) - @result{} nil + @result{} '() @end group @end example @end defun @@ -717,7 +717,7 @@ For another variant, see also @code{-drop-last} (@pxref{-drop-last}). @end group @group (-drop 17 '(1 2 3 4 5)) - @result{} nil + @result{} '() @end group @group (-drop 0 '(1 2 3 4 5)) @@ -741,7 +741,7 @@ See also: @code{-drop} (@pxref{-drop}). @end group @group (-drop-last 17 '(1 2 3 4 5)) - @result{} nil + @result{} '() @end group @group (-drop-last 0 '(1 2 3 4 5)) @@ -764,7 +764,7 @@ For another variant, see also @code{-drop-while} (@pxref{-drop-while}). @example @group (-take-while #'even? '(1 2 3 4)) - @result{} nil + @result{} '() @end group @group (-take-while #'even? '(2 4 5 6)) @@ -1444,7 +1444,7 @@ Return a list with running sums of items in @var{list}. @result{} '(1) @end group @group -(-running-sum nil) +(-running-sum '()) @error{} "Wrong type argument: consp, nil" @end group @end example @@ -1485,7 +1485,7 @@ Return a list with running products of items in @var{list}. @result{} '(1) @end group @group -(-running-product nil) +(-running-product '()) @error{} "Wrong type argument: consp, nil" @end group @end example @@ -1542,7 +1542,7 @@ Return the longest common prefix of @var{lists}. @end group @group (-common-prefix '(1 2) '(3 4) '(1 2)) - @result{} nil + @result{} '() @end group @group (-common-prefix '(1 2) '(1 2 3) '(1 2 3 4)) @@ -1562,7 +1562,7 @@ Return the longest common suffix of @var{lists}. @end group @group (-common-suffix '(1 2) '(3 4) '(1 2)) - @result{} nil + @result{} '() @end group @group (-common-suffix '(1 2 3 4) '(2 3 4) '(3 4)) @@ -3228,8 +3228,8 @@ backward compatibility and is otherwise deprecated. @result{} '(1) @end group @group -(-list nil) - @result{} nil +(-list '()) + @result{} '() @end group @group (-list '(1 2 3)) @@ -4083,8 +4083,8 @@ See also: @code{-map-indexed} (@pxref{-map-indexed}). @result{} '((c 2) (b 1) (a 0)) @end group @group -(let (l) (--each-indexed nil (push it l)) l) - @result{} nil +(let (l) (--each-indexed '() (push it l)) l) + @result{} '() @end group @end example @end defun @@ -4153,7 +4153,7 @@ This function's anaphoric counterpart is @code{--dotimes}. @end group @group (let (s) (-dotimes 0 (lambda (n) (push n s))) s) - @result{} nil + @result{} '() @end group @group (let (s) (--dotimes 5 (push it s)) s) diff --git a/dev/examples.el b/dev/examples.el index 01e12b3..391d16d 100644 --- a/dev/examples.el +++ b/dev/examples.el @@ -244,7 +244,7 @@ new list." (defexamples -take (-take 3 '(1 2 3 4 5)) => '(1 2 3) (-take 17 '(1 2 3 4 5)) => '(1 2 3 4 5) - (-take 0 '(1 2 3 4 5)) => () + (-take 0 '(1 2 3 4 5)) => '() (-take 0 ()) => () (-take -1 ()) => () (-take -1 '(1)) => () @@ -264,7 +264,7 @@ new list." (defexamples -drop (-drop 3 '(1 2 3 4 5)) => '(4 5) - (-drop 17 '(1 2 3 4 5)) => () + (-drop 17 '(1 2 3 4 5)) => '() (-drop 0 '(1 2 3 4 5)) => '(1 2 3 4 5) (-drop 0 ()) => () (-drop -1 ()) => () @@ -275,7 +275,7 @@ new list." (defexamples -drop-last (-drop-last 3 '(1 2 3 4 5)) => '(1 2) - (-drop-last 17 '(1 2 3 4 5)) => () + (-drop-last 17 '(1 2 3 4 5)) => '() (-drop-last 0 '(1 2 3 4 5)) => '(1 2 3 4 5) (-drop-last 0 ()) => () (-drop-last -1 ()) => () @@ -285,7 +285,7 @@ new list." (let ((l (list 1 2))) (eq (-drop-last 0 l) l)) => nil) (defexamples -take-while - (-take-while #'even? '(1 2 3 4)) => () + (-take-while #'even? '(1 2 3 4)) => '() (-take-while #'even? '(2 4 5 6)) => '(2 4) (--take-while (< it 4) '(1 2 3 4 3 2 1)) => '(1 2 3) (--take-while t ()) => () @@ -536,7 +536,7 @@ new list." (defexamples -running-sum (-running-sum '(1 2 3 4)) => '(1 3 6 10) (-running-sum '(1)) => '(1) - (-running-sum ()) !!> (wrong-type-argument consp ())) + (-running-sum '()) !!> (wrong-type-argument consp ())) (defexamples -product (-product '()) => 1 @@ -546,7 +546,7 @@ new list." (defexamples -running-product (-running-product '(1 2 3 4)) => '(1 2 6 24) (-running-product '(1)) => '(1) - (-running-product ()) !!> (wrong-type-argument consp ())) + (-running-product '()) !!> (wrong-type-argument consp ())) (defexamples -inits (-inits '(1 2 3 4)) => '(nil (1) (1 2) (1 2 3) (1 2 3 4)) @@ -560,7 +560,7 @@ new list." (defexamples -common-prefix (-common-prefix '(1)) => '(1) - (-common-prefix '(1 2) '(3 4) '(1 2)) => () + (-common-prefix '(1 2) '(3 4) '(1 2)) => '() (-common-prefix '(1 2) '(1 2 3) '(1 2 3 4)) => '(1 2) (-common-prefix () '(1 2) '(1 2)) => () (-common-prefix '(1 2) '(1 2) ()) => () @@ -572,7 +572,7 @@ new list." (defexamples -common-suffix (-common-suffix '(1)) => '(1) - (-common-suffix '(1 2) '(3 4) '(1 2)) => () + (-common-suffix '(1 2) '(3 4) '(1 2)) => '() (-common-suffix '(1 2 3 4) '(2 3 4) '(3 4)) => '(3 4) (-common-suffix () '(1 2) '(1 2)) => () (-common-suffix '(1 2) '(1 2) ()) => () @@ -1130,7 +1130,7 @@ value rather than consuming a list to produce a single value." (defexamples -list (-list 1) => '(1) - (-list ()) => () + (-list '()) => '() (-list '(1 2 3)) => '(1 2 3) (-list 1 2 3) => '(1 2 3) (let ((l (list 1 2))) (setcar (-list l) 3) l) => '(3 2) @@ -1583,7 +1583,7 @@ value rather than consuming a list to produce a single value." (defexamples -each-indexed (let (l) (-each-indexed '(a b c) (lambda (i x) (push (list x i) l))) l) => '((c 2) (b 1) (a 0)) (let (l) (--each-indexed '(a b c) (push (list it it-index) l)) l) => '((c 2) (b 1) (a 0)) - (let (l) (--each-indexed () (push it l)) l) => () + (let (l) (--each-indexed '() (push it l)) l) => '() (let (l) (-each-indexed () (lambda (_ x) (push x l))) l) => ()) (defexamples -each-r @@ -1609,7 +1609,7 @@ value rather than consuming a list to produce a single value." (defexamples -dotimes (let (s) (-dotimes 3 (lambda (n) (push n s))) s) => '(2 1 0) - (let (s) (-dotimes 0 (lambda (n) (push n s))) s) => () + (let (s) (-dotimes 0 (lambda (n) (push n s))) s) => '() (let (s) (--dotimes 5 (push it s)) s) => '(4 3 2 1 0) (let (s) (--dotimes 0 (push it s)) s) => () (let (s) (--dotimes 3 (push it s) (setq it -1)) s) => '(2 1 0)