emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash d98f5a0 235/316: Update for -iota


From: ELPA Syncer
Subject: [elpa] externals/dash d98f5a0 235/316: Update for -iota
Date: Mon, 15 Feb 2021 15:58:08 -0500 (EST)

branch: externals/dash
commit d98f5a02e28b26f85eab0e5d94c153e4d563aee6
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Update for -iota
    
    * dash.el (-iota): Tiny simplification.
    * dev/examples.el (-iota): Add more tests.
    
    * README.md:
    * dash.texi: Regenerate docs.
    
    Re: #207.
---
 README.md       | 15 +++++++++++++++
 dash.el         |  2 +-
 dash.texi       | 24 ++++++++++++++++++++++++
 dev/examples.el |  7 ++++++-
 4 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 778fa2c..74d8c55 100644
--- a/README.md
+++ b/README.md
@@ -270,6 +270,7 @@ Other list functions not fit to be classified elsewhere.
 * [-snoc](#-snoc-list-elem-rest-elements) `(list elem &rest elements)`
 * [-interpose](#-interpose-sep-list) `(sep list)`
 * [-interleave](#-interleave-rest-lists) `(&rest lists)`
+* [-iota](#-iota-count-optional-start-step) `(count &optional start step)`
 * [-zip-with](#-zip-with-fn-list1-list2) `(fn list1 list2)`
 * [-zip](#-zip-rest-lists) `(&rest lists)`
 * [-zip-lists](#-zip-lists-rest-lists) `(&rest lists)`
@@ -1794,6 +1795,20 @@ Return a new list of the first item in each list, then 
the second etc.
 (-interleave '(1 2 3) '("a" "b")) ;; => '(1 "a" 2 "b")
 ```
 
+#### -iota `(count &optional start step)`
+
+Return a list containing `count` numbers.
+Starts from `start` and adds `step` each time.  The default `start` is
+zero, the default `step` is 1.
+This function takes its name from the corresponding primitive in
+the `apl` language.
+
+```el
+(-iota 6) ;; => '(0 1 2 3 4 5)
+(-iota 4 2.5 -2) ;; => '(2.5 0.5 -1.5 -3.5)
+(-iota -1) ;; Error
+```
+
 #### -zip-with `(fn list1 list2)`
 
 Zip the two lists `list1` and `list2` using a function `fn`.  This
diff --git a/dash.el b/dash.el
index e1c9aca..68d2749 100644
--- a/dash.el
+++ b/dash.el
@@ -2705,7 +2705,7 @@ Starts from START and adds STEP each time.  The default 
START is
 zero, the default STEP is 1.
 This function takes its name from the corresponding primitive in
 the APL language."
-  (when (not (natnump count))
+  (unless (natnump count)
     (signal 'wrong-type-argument (list #'natnump count)))
   (or start (setq start 0))
   (or step (setq step 1))
diff --git a/dash.texi b/dash.texi
index 352e790..ee38333 100644
--- a/dash.texi
+++ b/dash.texi
@@ -2710,6 +2710,30 @@ Return a new list of the first item in each list, then 
the second etc.
 @end example
 @end defun
 
+@anchor{-iota}
+@defun -iota (count &optional start step)
+Return a list containing @var{count} numbers.
+Starts from @var{start} and adds @var{step} each time.  The default 
@var{start} is
+zero, the default @var{step} is 1.
+This function takes its name from the corresponding primitive in
+the @var{apl} language.
+
+@example
+@group
+(-iota 6)
+    @result{} '(0 1 2 3 4 5)
+@end group
+@group
+(-iota 4 2.5 -2)
+    @result{} '(2.5 0.5 -1.5 -3.5)
+@end group
+@group
+(-iota -1)
+    @result{} wrong-type-argument
+@end group
+@end example
+@end defun
+
 @anchor{-zip-with}
 @defun -zip-with (fn list1 list2)
 Zip the two lists @var{list1} and @var{list2} using a function @var{fn}.  This
diff --git a/dev/examples.el b/dev/examples.el
index a0f1975..2ab60a7 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -882,7 +882,12 @@ value rather than consuming a list to produce a single 
value."
   (defexamples -iota
     (-iota 6) => '(0 1 2 3 4 5)
     (-iota 4 2.5 -2) => '(2.5 0.5 -1.5 -3.5)
-    (-iota -1) !!> wrong-type-argument)
+    (-iota -1) !!> wrong-type-argument
+    (-iota 0) => ()
+    (-iota 0 nil 0) => ()
+    (-iota 1 nil 0) => '(0)
+    (-iota 1) => '(0)
+    (-iota 1 nil -1) => '(0))
 
   (defexamples -zip-with
     (-zip-with '+ '(1 2 3) '(4 5 6)) => '(5 7 9)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]