-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
featureNew feature or requestNew feature or request
Description
My first attempt at implementing partition looked like this:
(defn partition [n coll]
(->> coll (iter) (,) (* n) (apply zip)))This doesn't work anymore because we removed apply. I wasn't sure if it was redundant or not at the time. But let's try it with the new syntax.
=> (defn partition-v1 [n coll]
... (->> coll iter , (* n) (zip #*)))
...
LexException: Ran into a RPAREN where it wasn't expected.Not good. apply still has uses, apparently. I'm not sure how well I liked the old version, but it feels like something should replace it, since #*/#** can't always do it.
You can sort of work around this with xi
=> (require [hy.extra.anaphoric [xi]])
None
=> (defn partition-v2 [n coll]
... (-> coll iter , (* n) ((xi zip #* x1))))def partition_v2(n, coll):
return (lambda x1: zip(*x1))(((iter(coll),) * n))
NoneBut this adds a useless lambda in the compilation. apply didn't require an extra call like this. Maybe some kind of macro could work.
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request