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

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

[elpa] externals/dash 8248997 234/316: Merge pull request #207 from holo


From: ELPA Syncer
Subject: [elpa] externals/dash 8248997 234/316: Merge pull request #207 from holomorph/iota
Date: Mon, 15 Feb 2021 15:58:07 -0500 (EST)

branch: externals/dash
commit 82489971fd759cd22b095576ebb4c5ca38cdc17b
Merge: f975634 d308676
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Merge pull request #207 from holomorph/iota
---
 dash.el         | 17 +++++++++++++++++
 dev/examples.el |  5 +++++
 2 files changed, 22 insertions(+)

diff --git a/dash.el b/dash.el
index 053eabf..e1c9aca 100644
--- a/dash.el
+++ b/dash.el
@@ -2699,6 +2699,23 @@ The items for the comparator form are exposed as \"it\" 
and \"other\"."
   (declare (debug (form form)))
   `(-min-by (lambda (it other) ,form) ,list))
 
+(defun -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."
+  (when (not (natnump count))
+    (signal 'wrong-type-argument (list #'natnump count)))
+  (or start (setq start 0))
+  (or step (setq step 1))
+  (if (zerop step) (make-list count start)
+    (let (result)
+      (while (<= 0 (setq count (1- count)))
+        (push start result)
+        (setq start (+ start step)))
+      (nreverse result))))
+
 (defun -fix (fn list)
   "Compute the (least) fixpoint of FN with initial input LIST.
 
diff --git a/dev/examples.el b/dev/examples.el
index d83d282..a0f1975 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -879,6 +879,11 @@ value rather than consuming a list to produce a single 
value."
     (-interleave '(1 2 3) '("a" "b" "c" "d")) => '(1 "a" 2 "b" 3 "c")
     (-interleave) => nil)
 
+  (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)
+
   (defexamples -zip-with
     (-zip-with '+ '(1 2 3) '(4 5 6)) => '(5 7 9)
     (-zip-with 'cons '(1 2 3) '(4 5 6)) => '((1 . 4) (2 . 5) (3 . 6))



reply via email to

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