Remove uses of apply
from /hy
This commit is contained in:
parent
2d863abc85
commit
75e4ad8304
@ -27,7 +27,7 @@
|
|||||||
(when (not (first active))
|
(when (not (first active))
|
||||||
(assoc active 0 True)
|
(assoc active 0 True)
|
||||||
(while (> (len accumulated) 0)
|
(while (> (len accumulated) 0)
|
||||||
(setv result (apply f (.pop accumulated))))
|
(setv result (f #* (.pop accumulated))))
|
||||||
(assoc active 0 False)
|
(assoc active 0 False)
|
||||||
result)))
|
result)))
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
(setv output None)
|
(setv output None)
|
||||||
(for [[i f] (.items (get self._fns self.f.__module__ self.f.__name__))]
|
(for [[i f] (.items (get self._fns self.f.__module__ self.f.__name__))]
|
||||||
(when (.fn? self i args kwargs)
|
(when (.fn? self i args kwargs)
|
||||||
(setv output (apply f args kwargs))
|
(setv output (f #* args #** kwargs))
|
||||||
(break)))
|
(break)))
|
||||||
(if output
|
(if output
|
||||||
output
|
output
|
||||||
@ -37,10 +37,10 @@
|
|||||||
|
|
||||||
(defn multi-decorator [dispatch-fn]
|
(defn multi-decorator [dispatch-fn]
|
||||||
(setv inner (fn [&rest args &kwargs kwargs]
|
(setv inner (fn [&rest args &kwargs kwargs]
|
||||||
(setv dispatch-key (apply dispatch-fn args kwargs))
|
(setv dispatch-key (dispatch-fn #* args #** kwargs))
|
||||||
(if (in dispatch-key inner.--multi--)
|
(if (in dispatch-key inner.--multi--)
|
||||||
(apply (get inner.--multi-- dispatch-key) args kwargs)
|
((get inner.--multi-- dispatch-key) #* args #** kwargs)
|
||||||
(apply inner.--multi-default-- args kwargs))))
|
(inner.--multi-default-- #* args #** kwargs))))
|
||||||
(setv inner.--multi-- {})
|
(setv inner.--multi-- {})
|
||||||
(setv inner.--doc-- dispatch-fn.--doc--)
|
(setv inner.--doc-- dispatch-fn.--doc--)
|
||||||
(setv inner.--multi-default-- (fn [&rest args &kwargs kwargs] None))
|
(setv inner.--multi-default-- (fn [&rest args &kwargs kwargs] None))
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
`(do
|
`(do
|
||||||
(import [pycallgraph [PyCallGraph]]
|
(import [pycallgraph [PyCallGraph]]
|
||||||
[pycallgraph.output [GraphvizOutput]])
|
[pycallgraph.output [GraphvizOutput]])
|
||||||
(with* [(apply PyCallGraph [] {"output" (GraphvizOutput)})]
|
(with* [(PyCallGraph :output (GraphvizOutput)))]
|
||||||
~@body)))
|
~@body)))
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +29,6 @@
|
|||||||
(.disable ~g!hy-pr)
|
(.disable ~g!hy-pr)
|
||||||
(setv ~g!hy-s (StringIO))
|
(setv ~g!hy-s (StringIO))
|
||||||
(setv ~g!hy-ps
|
(setv ~g!hy-ps
|
||||||
(.sort-stats (apply pstats.Stats [~g!hy-pr] {"stream" ~g!hy-s})))
|
(.sort-stats (pstats.Stats ~g!hy-pr :stream ~g!hy-s)))
|
||||||
(.print-stats ~g!hy-ps)
|
(.print-stats ~g!hy-ps)
|
||||||
(print (.getvalue ~g!hy-s))))
|
(print (.getvalue ~g!hy-s))))
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
first-f (next rfs)
|
first-f (next rfs)
|
||||||
fs (tuple rfs))
|
fs (tuple rfs))
|
||||||
(fn [&rest args &kwargs kwargs]
|
(fn [&rest args &kwargs kwargs]
|
||||||
(setv res (apply first-f args kwargs))
|
(setv res (first-f #* args #** kwargs))
|
||||||
(for* [f fs]
|
(for* [f fs]
|
||||||
(setv res (f res)))
|
(setv res (f res)))
|
||||||
res))))
|
res))))
|
||||||
@ -45,7 +45,7 @@
|
|||||||
(defn complement [f]
|
(defn complement [f]
|
||||||
"Create a function that reverses truth value of another function"
|
"Create a function that reverses truth value of another function"
|
||||||
(fn [&rest args &kwargs kwargs]
|
(fn [&rest args &kwargs kwargs]
|
||||||
(not (apply f args kwargs))))
|
(not (f #* args #** kwargs))))
|
||||||
|
|
||||||
(defn cons [a b]
|
(defn cons [a b]
|
||||||
"Return a fresh cons cell with car = a and cdr = b"
|
"Return a fresh cons cell with car = a and cdr = b"
|
||||||
@ -160,7 +160,7 @@
|
|||||||
(defn drop-last [n coll]
|
(defn drop-last [n coll]
|
||||||
"Return a sequence of all but the last n elements in coll."
|
"Return a sequence of all but the last n elements in coll."
|
||||||
(setv iters (tee coll))
|
(setv iters (tee coll))
|
||||||
(map first (apply zip [(get iters 0)
|
(map first (zip #* [(get iters 0)
|
||||||
(drop n (get iters 1))])))
|
(drop n (get iters 1))])))
|
||||||
|
|
||||||
(defn empty? [coll]
|
(defn empty? [coll]
|
||||||
@ -250,7 +250,7 @@
|
|||||||
|
|
||||||
(defn interleave [&rest seqs]
|
(defn interleave [&rest seqs]
|
||||||
"Return an iterable of the first item in each of seqs, then the second etc."
|
"Return an iterable of the first item in each of seqs, then the second etc."
|
||||||
(chain.from-iterable (apply zip seqs)))
|
(chain.from-iterable (zip #* seqs)))
|
||||||
|
|
||||||
(defn interpose [item seq]
|
(defn interpose [item seq]
|
||||||
"Return an iterable of the elements of seq separated by item"
|
"Return an iterable of the elements of seq separated by item"
|
||||||
@ -275,7 +275,7 @@
|
|||||||
set of arguments and collects the results into a list."
|
set of arguments and collects the results into a list."
|
||||||
(setv fs (cons f fs))
|
(setv fs (cons f fs))
|
||||||
(fn [&rest args &kwargs kwargs]
|
(fn [&rest args &kwargs kwargs]
|
||||||
(list-comp (apply f args kwargs) [f fs])))
|
(list-comp (f #* args #** kwargs) [f fs])))
|
||||||
|
|
||||||
(defn last [coll]
|
(defn last [coll]
|
||||||
"Return last item from `coll`"
|
"Return last item from `coll`"
|
||||||
@ -285,7 +285,7 @@
|
|||||||
"Return a dotted list construed from the elements of the argument"
|
"Return a dotted list construed from the elements of the argument"
|
||||||
(if (not tl)
|
(if (not tl)
|
||||||
hd
|
hd
|
||||||
(cons hd (apply list* tl))))
|
(cons hd (list* #* tl))))
|
||||||
|
|
||||||
(defn macroexpand [form]
|
(defn macroexpand [form]
|
||||||
"Return the full macro expansion of form"
|
"Return the full macro expansion of form"
|
||||||
@ -350,8 +350,8 @@
|
|||||||
slices (genexpr (islice (get coll-clones start) start None step)
|
slices (genexpr (islice (get coll-clones start) start None step)
|
||||||
[start (range n)]))
|
[start (range n)]))
|
||||||
(if (is fillvalue -sentinel)
|
(if (is fillvalue -sentinel)
|
||||||
(apply zip slices)
|
(zip #* slices)
|
||||||
(apply zip-longest slices {"fillvalue" fillvalue})))
|
(zip-longest #* slices :fillvalue fillvalue)))
|
||||||
|
|
||||||
(defn pos? [n]
|
(defn pos? [n]
|
||||||
"Return true if n is > 0"
|
"Return true if n is > 0"
|
||||||
|
@ -207,7 +207,7 @@
|
|||||||
(setv retval (gensym))
|
(setv retval (gensym))
|
||||||
`(when (= --name-- "__main__")
|
`(when (= --name-- "__main__")
|
||||||
(import sys)
|
(import sys)
|
||||||
(setv ~retval (apply (fn [~@args] ~@body) sys.argv))
|
(setv ~retval ((fn [~@args] ~@body) #* sys.argv))
|
||||||
(if (integer? ~retval)
|
(if (integer? ~retval)
|
||||||
(sys.exit ~retval))))
|
(sys.exit ~retval))))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user