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
Your question boils down to: "How do I convert a number to a base-26 string with the alphabet A-Z?".
Here's one way to do that - probably not the most concise way, but making it more elegant is left as an exercise for the reader :).
Assume that numbers 0-25 map to 'A'-'Z', 26 maps to 'AA', etcetera. First we define a function
to-col
that converts an integer to a column keyword. You can use that function to generate an infinite sequence.That gives you a way to generate an infinite sequence of column keywords:
The essential clojure function for corecursion (and "tying the knot" is about it, no?) is iterate:
EDIT: Generalization of the function to return the "ordered" subsets of a set
As mentioned by jneira iterate feels like the right way to do this.
Here's an improvement on his function that should be clearer to understand as it involves less intermediate types. It is fully lazy unlike some of the other solutions based around loop/recur:
To use it simply provide it with an alphabet string e.g:
guys is this as simple as this or am i missing something .... of course the above program prints the required atring in reverse we can avoid that by using recursion or store it in a string to reverse it ...
Probably there is a way to remove the "for" duplication, but here is something that works for me:
This answer is wrong; hopefully in an educational way.
mathematically what you are asking for is a lazy sequence of all subsets of the infinite sequence of the alphabet.
project.clj:
using math.combanatorics: