(ns clojure.examples.hello (:gen-class)) (defn hello-world [username] (println (format "Hello, %s" username))) (hello-world "world") (defn is_leap_j[y] (= 0 (rem y 4))) (defn is_leap_g[y] (or (= 0 (rem y 400)) (and (= 0 (rem y 4)) (not= 0 (rem y 100))) ) ) (defn get_m [y] (let [ normal_md [ 31 28 31 30 31 30 31 31 30 31 30 31] leap_md [ 31 29 31 30 31 30 31 31 30 31 30 31] y1918_md [ 31 15 31 30 31 30 31 31 30 31 30 31] ] (cond (< y 1918) (if (true? (is_leap_j y)) leap_md normal_md) (> y 1918) (if (true? (is_leap_g y)) leap_md normal_md) :else y1918_md ) ) ) (defn get_md[y] (let [ day_of_pgm 256 md (get_m y) m_acc (map-indexed (fn [idx itm] [idx (reduce + (take (inc idx) md) ) ] ) md) m (first (filter (fn [n] (> (last n) day_of_pgm)) m_acc ) ) ] [(first m) (- (nth md (dec (first m))) (- (last m) day_of_pgm ) 1) ] ) ) ( let [ year 2016 md (get_md year) ] (printf "%02d.%02d.%04d" (last md) (inc (first md)) year ) )
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more