Delete anaphoric
docstrings
so they don't get desynchronized from the manual.
This commit is contained in:
parent
c7966920a6
commit
08abdd5af9
@ -12,13 +12,10 @@
|
|||||||
|
|
||||||
|
|
||||||
(defmacro ap-each [xs &rest body]
|
(defmacro ap-each [xs &rest body]
|
||||||
"Evaluate the body form for each element in the list."
|
|
||||||
(rit `(for [it ~xs] ~@body)))
|
(rit `(for [it ~xs] ~@body)))
|
||||||
|
|
||||||
|
|
||||||
(defmacro ap-each-while [xs form &rest body]
|
(defmacro ap-each-while [xs form &rest body]
|
||||||
"Evaluate the body form for each element in the list while the
|
|
||||||
predicate form evaluates to True."
|
|
||||||
(rit `(for [it ~xs]
|
(rit `(for [it ~xs]
|
||||||
(unless ~form
|
(unless ~form
|
||||||
(break))
|
(break))
|
||||||
@ -26,41 +23,33 @@
|
|||||||
|
|
||||||
|
|
||||||
(defmacro ap-map [form xs]
|
(defmacro ap-map [form xs]
|
||||||
"Yield elements evaluated in the form for each element in the list."
|
|
||||||
(rit `(gfor it ~xs ~form)))
|
(rit `(gfor it ~xs ~form)))
|
||||||
|
|
||||||
|
|
||||||
(defmacro ap-map-when [predfn rep xs]
|
(defmacro ap-map-when [predfn rep xs]
|
||||||
"Yield elements evaluated for each element in the list when the
|
|
||||||
predicate function returns True."
|
|
||||||
(rit `(gfor it ~xs (if (~predfn it) ~rep it))))
|
(rit `(gfor it ~xs (if (~predfn it) ~rep it))))
|
||||||
|
|
||||||
|
|
||||||
(defmacro ap-filter [form xs]
|
(defmacro ap-filter [form xs]
|
||||||
"Yield elements returned when the predicate form evaluates to True."
|
|
||||||
(rit `(gfor it ~xs :if ~form it)))
|
(rit `(gfor it ~xs :if ~form it)))
|
||||||
|
|
||||||
|
|
||||||
(defmacro ap-reject [form xs]
|
(defmacro ap-reject [form xs]
|
||||||
"Yield elements returned when the predicate form evaluates to False"
|
|
||||||
(rit `(gfor it ~xs :if (not ~form) it)))
|
(rit `(gfor it ~xs :if (not ~form) it)))
|
||||||
|
|
||||||
|
|
||||||
(defmacro ap-dotimes [n &rest body]
|
(defmacro ap-dotimes [n &rest body]
|
||||||
"Execute body for side effects `n' times, with it bound from 0 to n-1"
|
|
||||||
(rit `(for [it (range ~n)]
|
(rit `(for [it (range ~n)]
|
||||||
~@body)))
|
~@body)))
|
||||||
|
|
||||||
|
|
||||||
(defmacro ap-first [form xs]
|
(defmacro ap-first [form xs]
|
||||||
"Yield the first element that passes `form`"
|
|
||||||
(rit `(next
|
(rit `(next
|
||||||
(gfor it ~xs :if ~form it)
|
(gfor it ~xs :if ~form it)
|
||||||
None)))
|
None)))
|
||||||
|
|
||||||
|
|
||||||
(defmacro ap-last [form xs]
|
(defmacro ap-last [form xs]
|
||||||
"Yield the last element that passes `form`"
|
|
||||||
(setv x (gensym))
|
(setv x (gensym))
|
||||||
(rit `(do
|
(rit `(do
|
||||||
(setv ~x None)
|
(setv ~x None)
|
||||||
@ -70,7 +59,6 @@
|
|||||||
|
|
||||||
|
|
||||||
(defmacro! ap-reduce [form o!xs &optional [initial-value None]]
|
(defmacro! ap-reduce [form o!xs &optional [initial-value None]]
|
||||||
"Anaphoric form of reduce, `acc' and `it' can be used for a form"
|
|
||||||
(recur-sym-replace {'it (gensym) 'acc (gensym)} `(do
|
(recur-sym-replace {'it (gensym) 'acc (gensym)} `(do
|
||||||
(setv acc ~(if (none? initial-value)
|
(setv acc ~(if (none? initial-value)
|
||||||
`(do
|
`(do
|
||||||
@ -83,14 +71,6 @@
|
|||||||
|
|
||||||
|
|
||||||
(deftag % [expr]
|
(deftag % [expr]
|
||||||
"Makes an expression into a function with an implicit `%` parameter list.
|
|
||||||
|
|
||||||
A `%i` symbol designates the (1-based) ith parameter (such as `%3`).
|
|
||||||
Only the maximum `%i` determines the number of `%i` parameters--the
|
|
||||||
others need not appear in the expression.
|
|
||||||
`%*` and `%**` name the `&rest` and `&kwargs` parameters, respectively.
|
|
||||||
|
|
||||||
Nesting of `#%` forms is not recommended."
|
|
||||||
(setv %symbols (sfor a (flatten [expr])
|
(setv %symbols (sfor a (flatten [expr])
|
||||||
:if (and (symbol? a)
|
:if (and (symbol? a)
|
||||||
(.startswith a '%))
|
(.startswith a '%))
|
||||||
|
Loading…
Reference in New Issue
Block a user