This file contains hidden or 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
;;; The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. | |
;;; Find the sum of all the primes below two million. | |
(defn primes [n] | |
(loop [prime-list '(2) search-list (take-while #(< % n) (iterate inc 2))] | |
(let [prime-list-max (first prime-list) | |
search-list-next (filter #(not (zero? (mod % prime-list-max))) search-list)] | |
(if (< n (* prime-list-max prime-list-max)) | |
(sort (concat prime-list search-list-next)) | |
(recur (conj prime-list (first search-list-next)) search-list-next))))) |
This file contains hidden or 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
;;; In the 20x20 grid below, four numbers along a diagonal line have been marked in red. | |
;;; | |
;;; 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 | |
;;; 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 | |
;;; 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 | |
;;; 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 | |
;;; 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 | |
;;; 24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50 | |
;;; 32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70 | |
;;; 67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21 |
This file contains hidden or 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
;;; The sequence of triangle numbers is generated by adding the natural numbers. | |
;;; So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: | |
;;; | |
;;; 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... | |
;;; | |
;;; Let us list the factors of the first seven triangle numbers: | |
;;; | |
;;; 1: 1 | |
;;; 3: 1,3 | |
;;; 6: 1,2,3,6 |
This file contains hidden or 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
;;; http://melborne.github.com/2012/07/12/object-repeat-take-care-of-sequence/ | |
;;; を Clojure でやってみた。 | |
;;; 9.、10. は挫折www | |
;;; 2012/07/16 11:02 追記:9.、10.についての解答をtnoda さんが作成されました。 | |
;;; https://gist.github.com/3111930 の 9.、10. になります。 | |
;;; 1. 初項1、公差2の等差数列の最初の20項を求めなさい。 | |
(take 20 (iterate #(+ % 2) 1)) | |
;;; => (1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39) |
This file contains hidden or 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
;;; Clojure Programming Chapter 2. Functional Programming | |
;;; Example 2-1. Implementation of a mutable integer in "Clojure" | |
(defprotocol IStatefulInteger | |
(setInt [this new-state]) | |
(intValue [this])) | |
(deftype StatefulInteger [^{:volatile-mutable true} state] | |
IStatefulInteger | |
(setInt [this new-state] (set! state new-state)) | |
(intValue [this] state) |
This file contains hidden or 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
(defn print-logger | |
[writer] | |
#(binding [*out* writer] | |
(println %))) | |
(def *out*-logger (print-logger *out*)) | |
;= #'user/*out*-logger | |
(*out*-logger "hello") | |
; hello | |
;= nil |
This file contains hidden or 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
;; @___otabat___ さんのツイート https://twitter.com/___otabat___/status/230890089218195456 | |
;; より引用 | |
;; 「Clojureでmapリテラルを使うとき、8対目まではarray-map、9対目からhash-mapに変わるなどデータと内部実装が異なるのは注意。」 | |
;; を試してみた。 | |
user=> (class {:a 10 :b 20}) | |
;= clojure.lang.PersistentArrayMap | |
user=> (class {:a 10 :b 20 :c 30 :d 40 :e 50 :f 60 :g 70 :h 80}) | |
;= clojure.lang.PersistentArrayMap (:a〜:h 8対まで) | |
user=> (class {:a 10 :b 20 :c 30 :d 40 :e 50 :f 60 :g 70 :h 80 :i 90}) | |
;= clojure.lang.PersistentHashMap (:a〜:i 9対、PersistentHashMap に変わった!!) |
This file contains hidden or 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
# http://d.hatena.ne.jp/haru-s/20110405/1302006637 に答えがそのままあるが、一応メモ | |
# github fork 追従 で見つけた | |
$ git remote | |
origin | |
# 本家のリモートリポジトリの短縮名を登録する. | |
$ git remote add github git://github.com/liquidz/misaki.git | |
# 本家の更新をローカルで反映させる. |
This file contains hidden or 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
diff --git a/project.clj b/project.clj | |
index 99624f3..5b53fba 100644 | |
--- a/project.clj | |
+++ b/project.clj | |
@@ -9,6 +9,7 @@ | |
[clj-time "0.3.7"] | |
[clj-text-decoration "0.0.1"] | |
[clj-pretty-error "0.0.5"] | |
+ [clj-gntp "0.0.1"] ; https://github.com/mattn/clj-gntp | |
[uochan/watchtower "0.1.2"] |
This file contains hidden or 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
diff --git a/src/misaki/config.clj b/src/misaki/config.clj | |
index ee06fbe..dfffb85 100644 | |
--- a/src/misaki/config.clj | |
+++ b/src/misaki/config.clj | |
@@ -57,8 +57,6 @@ | |
(declare ^:dynamic *post-sort-type*) | |
;; Compile options for ClojureScript | |
(declare ^:dynamic *cljs-compile-options*) | |
-;; Current site data | |
-(declare ^:dynamic *site*) |