Sha256: 675751557eb529dc2916350b31cd7041b4129aa46e15da6b4cabdc264ec90b9d
Contents?: true
Size: 643 Bytes
Versions: 188
Compression:
Stored size: 643 Bytes
Contents
(ns rotational-cipher) (defn ^:private spinner [s a] (let [a (int a) spin (fn [c] (mod (+ c s) 26))] (fn [c] (let [c (- (int c) a)] (char (+ (spin c) a)))))) (defn ^:private upper-spinner [s] (spinner s \A)) (defn ^:private lower-spinner [s] (spinner s \a)) (defn ^:private cipher [spin] (let [upper-spin (upper-spinner spin) lower-spin (lower-spinner spin)] (fn [c] (cond (Character/isUpperCase c) (upper-spin c) (Character/isLowerCase c) (lower-spin c) :default c)))) (defn rotate [text spin] (let [cipher (cipher spin)] (apply str (map cipher text)) ))
Version data entries
188 entries across 188 versions & 1 rubygems