Last active
June 11, 2020 04:53
-
-
Save aoba17/a5ba34a2209a4a7110a5f97bc35ab8f9 to your computer and use it in GitHub Desktop.
Clojureメモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; N-gram | |
(defn n-gram-index | |
"N-gram インデックスの作成" | |
[n s] | |
(map clojure.string/join (partition n 1 s))) | |
(def trigram-index (partial n-gram-index 3)) | |
;; 2つの日付の差分(日数)を取得 | |
(def dt-a #inst "2020-05-01") | |
(def dt-b #inst "2020-05-05") | |
(def mills<->days (* 1000 60 60 24)) | |
(defn get-duration | |
"2つの日付の期間を日数で取得" | |
[dt-a dt-b] | |
(/ (- (.getTime dt-b) | |
(.getTime dt-a)) | |
mills<->days)) | |
(get-duration dt-a dt-b) ;-> 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment