Thank you for your example. I especially like doing sl, su, sd in one line.
However: user=> ((gen-crypto) "1 for me, 2 for you.") "1 zdu gy, 2 zdu fdx." The numbers are coming through without translation. I believe defining digit as: user=> (map #(char (+ 48 %)) (range 10)) (\0 \1 \2 \3 \4 \5 \6 \7 \8 \9) will fix that issue. Or (map char (range 48 58)) On Monday, June 10, 2013 7:42:45 PM UTC-7, Kelker Ryan wrote: > > Here's my re-write. > > > user> (defn gen-crypto [] > (let [atoz (range 65 91) > upper (map char atoz) > lower (map #(char (+ % 32)) atoz) > digit (range 10) > [sl su sd] (map shuffle [lower upper digit]) > encrypt (reduce conj > (map hash-map > (concat lower upper digit) > (concat sl su sd)))] > (fn [s] > (apply str (map #(encrypt % %) s))))) > #'user/gen-crypto > user> ((gen-crypto) "abc")"ghm" > user> ((gen-crypto) "abc")"efz" > > > 11.06.2013, 10:31, "Shannon Severance" <s...@s53.me <javascript:>>: > > > I'm new to Clojure, but with some lisp experience, I've dabbled in > Scheme for a few years. Used Racket earlier this year for a couple of > sectoins of a MOOC. And occasionally write Emacs lisp. > > > > The idea is to create cyptograms. These are word puzzles using simple > ciphers, and not meant for keeping real secrets. > > > > ;; -> (String -> String) > > ;; Returns a function that takes a string and produces a cryptogram. > > ;; Multiple calls to make-crypto will return different cryptos > > ;; each with different substitution keys. Multiple calls to a given > > ;; crypto returned by make-crypto will use the same substitution key. > > > > (defn make-crypto [] > > (let [lower (seq "abcdefghijklmnopqrstuvwxyz") > > upper (seq "ABCDEFGHIJKLMNOPQRSTUVWXYZ") > > digit (seq "0123456789") > > > > shuffled-lower (shuffle lower) > > shuffled-upper (shuffle upper) > > shuffled-digit (shuffle digit) > > > > encrypt (reduce > > conj > > (map (partial assoc {}) > > (concat lower upper digit) > > (concat shuffled-lower shuffled-upper > shuffled-digit)))] > > (fn [s] > > (apply str (map #(encrypt % %) s))))) > > > > To me, it looks like too much code in defining the encrypt map. But I > do not know how. > > > > -- Shannon > > > > -- > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clo...@googlegroups.com<javascript:> > > Note that posts from new members are moderated - please be patient with > your first post. > > To unsubscribe from this group, send email to > > clojure+u...@googlegroups.com <javascript:> > > 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+u...@googlegroups.com <javascript:>. > > 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.