Closed eval closed 1 year ago
Can you show an example of how this would be used?
I'm working on documenting base16/32 encoding and tripped over (int \a) ;;=> 0
. With js/String
this would be:
(defn char->long [ch]
(.charCodeAt ch))
(def boxes-per-row 8)
(doseq [n "Hello"]
(draw-related-boxes (number-as-bits (char->long n) 8)))
Would it be helpful to include the char->long
helper?
Thanks for the clarification! Yes, that would be nice, and adding an example to the user guide would help people discover it. If learning AsciiDoc/Antora is too much, I could help with the formatting, but perhaps it will be clear enough by context if you look in doc/modules/root/pages
.
And I should have already said: thank you so much for the contribution! 😄
Thanks for the quick feedback and pointers @brunchboy.
I added the helper and some documentation. Struggled a bit with the wording so feel free to amend where needed.
Thanks again, @eval, this is a great addition. I’ll see if I can get another release built that includes it. I have to remember my rusty npm skills.
Ah, Asciidoctor wants to turn “->” into “→” in the function description, but I figured out how to stop it by escaping. I think I will tweak the wording of the reason why we make the Math and String objects available a bit while I am in there, but your submission was great.
🙏🏻 for the merge and the new release James! And good to know about the arrow :)
This allows for the clj-equivalent of
(int \a)
, i.e.(.charCodeAt \a)
.