Looks nice, although I like Dan's explicit definition of char sequences. One thing that threw me at first was the double arg in the function #(encrypt % %). It took a while before I realized you were supplying each character as both the map key value and a default return value (thus, a non-alphanumeric char like * would come through w/o translation).
While this works, what I would do instead is be more explicit that only certain chars are allowed in the first place. So, I'd add a filter up front that would throw an exception if any non-alphanumeric char were encountered. I can't tell you how many times this "fail-fast" type of behavior has saved me, since it makes bugs easy to find rather than burying the cause of a problem (kinda like getting an error at compile-type instead of at runtime). Alan Thompson On Wed, Jun 12, 2013 at 5:30 PM, Shannon Severance <s...@s53.me> wrote: > Thank you all, I've learned something from each entry. My latest version, > incorporating some of the changes suggested: > > (defn make-crypto [] > (let [lower (map char (range (int \a) (inc (int \z)))) > upper (map char (range (int \A) (inc (int \Z)))) > digit (map char (range (int \0) (inc (int \9)))) > > [sl su sd] (map shuffle [lower upper digit]) > > encrypt (zipmap (concat lower upper digit) > (concat sl su sd))] > (fn [s] > (apply str (map #(encrypt % %) s))))) > > I specified the range the way I did because I wanted meaningful start and > end points, I don't have the code points for many characters memorized. > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.