aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <cbeok@protonmail.com>2020-07-10 08:24:27 -0500
committerColin Okay <cbeok@protonmail.com>2020-07-10 08:24:27 -0500
commit674824f91bf30c31086a069ce55a0d98ff279d6d (patch)
tree9651d5dff24571846bdf4f4311f10563b453452e
parent389582c4d1e18de495e05c48e9309ba668147705 (diff)
added indexed!
-rw-r--r--README.md3
-rw-r--r--gtwiwtg.lisp4
2 files changed, 6 insertions, 1 deletions
diff --git a/README.md b/README.md
index 0961490..c8c6924 100644
--- a/README.md
+++ b/README.md
@@ -189,7 +189,7 @@ You can see some of these in action in the examples section at the top of this d
### The Combination and Transformation Functions
You can create more intersting and more specific generators by using a
-few higher-order functions to transform combine and transform simple generators.
+few higher-order functions to combine and transform simple generators.
These transformations are desirable because they can be performed
before any elements are produced.
@@ -248,6 +248,7 @@ Here are some simple examples of their use:
### The Other Combinations and Transformations
- `(zip! gen1 &rest gens)` is shorthand for `(map! #'list gen1 gen2 ...)`
+- `(indexed! gen)` is shorthand for `(zip! (range) gen)`
- `(concat! gen &rest gens)` is shorthand for `(inflate! #'identity (seq (list* gen1 gen2 ...)))`
- `(skip! n gen)` produces a generator by skipping the first `n` values in `gen`
- `(skip-while! pred gen)` produces a generator by skippng elements of `gen` while `pred` is `t`
diff --git a/gtwiwtg.lisp b/gtwiwtg.lisp
index caf5be7..0ac6578 100644
--- a/gtwiwtg.lisp
+++ b/gtwiwtg.lisp
@@ -462,6 +462,10 @@ Error Conditions:
"Is a shortcut for (MAP! #'LIST GEN1 GEN2 ...)"
(apply #'map! #'list gen gens))
+(defun indexed! (gen)
+ "Is shorthand for (ZIP! (RANGE) GEN)"
+ (zip! (range) gen))
+
(defun merge! (comparator gen1 gen2 &rest gens)
"Emulates the behavior of MERGE (in the ANSI standard), but for generators.