No. | タイトル | 担当 | レベル |
---|---|---|---|
1 | Java のクラスの作り方 | @tnoda\_ | 未経験者 |
2 | Docstring 逐条講義 | @tnoda\_ | ビギナー |
3 | gen-class の内部実装の話 | @athos0220 | 上級者 |
4 | アノテーションの使い方 | @tnoda\_ | 中級者 |
5 | gen-class クイズ | @tnoda\_ | 中級者 |
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
(ns repeating-decimal) | |
(defn repeating-decimal [n] | |
(loop [rem 1 rems #{} divs [] i 0] | |
(let [div (int (/ (* rem 10) n)) | |
rem (mod (* rem 10) n)] | |
(if (and (not= rem 0) (contains? rems rem)) | |
[n divs] | |
(when (not= rem 0) | |
(recur rem (conj rems rem) (conj divs div) (inc i))))))) |
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 with-retry [n f] | |
(letfn [(try-once [i] | |
(try | |
(f) | |
(catch Exception e | |
(if (pos? i) | |
#(try-once (dec i)) | |
(throw e)))))] | |
(trampoline try-once n))) |
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
(def actions | |
(repeatedly (read) (fn [] [(read) (read)]))) | |
(defn step [[[[t op] & as' :as as] temp temps] time] | |
(let [temp' (+ temp (if (= time t) (get '{out 3 in 5} op) 0))] | |
[(if (= time t) as' as), (max (dec temp') 0), (conj temps temp')])) | |
(defn calc [actions] | |
(let [zs (count (filter zero? (last (reduce step [actions 0 []] (range 24)))))] | |
(+ zs (* 2 (- 24 zs))))) |
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
(def players | |
(->> (repeatedly #(read *in* false nil)) | |
(take-while identity) | |
(map-indexed #(vector % ('{J 11 Q 12 K 13 A 14 2 15} %2 %2))) | |
(into clojure.lang.PersistentQueue/EMPTY))) | |
(defn solve [ps] | |
(loop [[[id n :as p] :as ps] ps, card nil, passes 0, winners []] | |
(cond (empty? ps) winners | |
(= passes (count ps)) (recur ps nil 0 winners) |
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 include? [xs ys] | |
(let [ys' (frequencies ys)] | |
(reduce (fn [_ [e n]] | |
(or (some->> (ys' e) (<= n)) | |
(reduced false))) | |
true | |
(frequencies xs)))) |
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 include? [[x & xs :as xxs] [y & ys :as yys]] | |
(or (empty? xxs) | |
(and (not (empty? yys)) | |
(if (= x y) | |
(recur xs ys) | |
(recur xxs ys))))) |
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
> defmodule M do | |
> def f do | |
> x = 0 | |
> {fn -> x = 1 end, fn -> x end} | |
> end | |
> end | |
iex:4: warning: variable x is unused | |
{:module, M, | |
<<70, 79, 82, 49, 0, 0, 5, 24, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 124, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, | |
{:f, 0}} |
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
(ns redef-as-serializable.core) | |
(defmacro redef-as-serializable [& ts] | |
`(do ~@(for [t ts | |
:let [c (resolve t) | |
fields (mapv #(symbol (.getName %)) (.getDeclaredFields c))]] | |
`(deftype ~(symbol (str t \')) ~fields | |
java.io.Serializable)))) |
- Hubot: GitHub製ボットフレームワーク(CoffeeScript)
- アダプター: ボットを動かすサービスの差を吸収するレイヤー
- スクリプト: コマンドに対するアクションを規定