No problem. I re-wrote your latest version, so let me know what you think.
 
tdsl.core> (defn make-crypto []
             (let [char-range #(map char
                                    (range (int %1)
                                           (-> %2 int inc)))
                   [l u d] (map char-range [\a \A \0] [\z \Z \9])
                   [sl su sd] (map shuffle [l u d])
                   encrypt (zipmap (concat l u d) (concat sl su sd))]
               (fn [s] (apply str (map #(encrypt % %) s)))))
#'tdsl.core/make-crypto
tdsl.core> ((make-crypto) "1 potato 2 potato")
"6 hxnvnx 0 hxnvnx"
tdsl.core> ((make-crypto) "1 potato 2 potato")
"3 dszmzs 1 dszmzs"
 
13.06.2013, 09:30, "Shannon Severance" <s...@s53.me>:
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.
 
 

Reply via email to