Skip to content

Instantly share code, notes, and snippets.

View kimmowikman's full-sized avatar

Kimmo Wikman kimmowikman

  • Luoto Company Oy
View GitHub Profile
package fi.luotocompany.logger;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* Simple and secure logger by Kimmo Wikman, Luoto Company
*/
public class SimpleLogger {
@kimmowikman
kimmowikman / core.clj
Last active March 9, 2018 10:56
Clojure program that converts roman numeral to decimal.
(ns roman.core
(:require [clojure.string :as str]))
(def grammar '("^M{0,4}" "^CM|^CD|^D?C{0,3}" "^XC|^XL|^L?X{0,3}" "^IX|^IV|^V?I{0,3}"))
(def values {:M 1000 :D 500 :C 100 :L 50 :X 10 :V 5 :I 1})
(defn sum-tokens [tokens]
(reduce
#(if (< %1 %2) (- %2 %1) (+ %1 %2))
(map #((keyword (str %)) values) (seq tokens))))