I am using docjure and it needs a column map for its select-columns function. I would like to grab all my columns without having to specify it manually. How do I generate the following as a lazy infinite vector sequence [:A :B :C :D :E ... :AA :AB :AC .... :ZZ ... :XFD]?
相关问题
- Better Sequence Duplicate Remover
- Installation of Leiningen 2.X in Mac OS X
- R time series data, daily only working days
- Questions about Lists and other stuff in Clojure
- How do I add CORS to a compojure-api app?
相关文章
- Given a list and a bitmask, how do I return the va
- Factor Clojure code setting many different fields
- Does learning one Lisp help in learning the other?
- rxjs timeout to first value
- Better way to nest if-let in clojure
- Idiomatic approach for structuring Clojure source
- Is a “transparent” macrolet possible?
- Detect operating system in Clojure
I think this may be the kind of thing you were looking for (if not, well, at least it is what I thought the "correct" answer should be ;o).
Code in git. I suspect I am abusing
def
horribly, but it works.The idea is pretty simple: I take the output from the sequence and feed it back on itself. For each value in the output (which is also the input), I generate a new output by appending each of the letters in the seed sequence. Since this is circular it just keeps on going (there's an initial "" which is in the input, but not the output, that helps avoid creating something from nothing).
The process of feeding the output into the input is called "tying the knot" in a fairly famous paper for Haskell. But it's harder to do in Clojure because it's an eager language (and even lazy sequences aren't "lazy enough") - the only solution I could find was that mess with
def
(I suspect someone might do better withdelay
andforce
, but I had no luck).And maybe it could even be written as a map?
[updated 2012-07-19 with more compact code]
Related question with much better code in an answer at Tying the knot in Clojure: circular references without (explicit, ugly) mutation? (it's the same idea as jneira's answer).
For completeness, here's the final version using
iterate
: