- LT発表資料です
- Clojure CLIがインストールされていれば、以下で実行できます:
$ clj -Sdeps '{:deps {athos/form-and-env {:git/url "https://gist.github.com/athos/1e92959529dc60316cc2fff4ed3990ff.git" :sha "343f21f5dc5999d9eeef3d993a31755ebd9b84a4"}}}'
(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))) |
(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))))))) |
(require '[clojure.core.async :as a] | |
'[kitchen-async.promise :as p] | |
'[kitchen-async.promise.from-channel]) | |
(comment | |
;; cf. https://gist.github.com/swannodette/5888989 | |
(defn debounce | |
([c ms] (debounce (a/chan) c ms)) |
{:paths ["."] | |
:deps {clansi/clansi {:mvn/version "1.0.0"}}} |
(defn a&b [n] | |
(loop [n n, a (/ 1.0 (* 2 (Math/pow 3 0.5))), b (/ 1.0 3)] | |
(if (= n 0) | |
[a b] | |
(let [a' (/ (+ a b) 2)] | |
(recur (dec n) a' (Math/pow (* a' b) 0.5)))))) | |
;; => (time (/ 1 (first (a&b 100)))) | |
;; "Elapsed time: 0.04547 msecs" | |
;; 3.141592653589795 |
target/classes/cljam/io/bam/decoder$parse_option$fn__2824.class | |
69: invokevirtual #57 // Method java/nio/CharBuffer.flip:()Ljava/nio/CharBuffer; | |
target/classes/cljam/io/bcf/reader$parse_data_line_shallow.class | |
220: invokevirtual #94 // Method java/nio/ByteBuffer.position:(I)Ljava/nio/ByteBuffer; | |
target/classes/cljam/io/fasta/reader$create_ba.class | |
31: invokevirtual #35 // Method java/nio/ByteBuffer.clear:()Ljava/nio/ByteBuffer; | |
53: invokevirtual #35 // Method java/nio/ByteBuffer.clear:()Ljava/nio/ByteBuffer; | |
target/classes/cljam/io/fasta/reader$read_sequence.class | |
583: invokevirtual #212 // Method java/nio/CharBuffer.flip:()Ljava/nio/CharBuffer; | |
target/classes/cljam/io/fasta/reader$sequential_read1_BANG_.class |
$ clj -Sdeps '{:deps {athos/form-and-env {:git/url "https://gist.github.com/athos/1e92959529dc60316cc2fff4ed3990ff.git" :sha "343f21f5dc5999d9eeef3d993a31755ebd9b84a4"}}}'
(require '[jise.core :refer [defclass]]) | |
(defmacro defexception [ex-name] | |
`(do | |
^:public | |
(defclass ~ex-name [clojure.lang.ExceptionInfo] | |
^:public | |
(defm ~ex-name [^String msg# ^clojure.lang.IPersistentMap map#] | |
(super msg# map#)) | |
^:public |
(ns jise.extension.tagbody | |
(:require [jise.emit :as emit] | |
[jise.parse :as parse]) | |
(:import [clojure.asm Label MethodVisitor Opcodes])) | |
(defn parse-tagbody-body [body] | |
(loop [body body | |
tag nil | |
block [] | |
blocks []] |
{:paths ["."] | |
:deps {clj-skkserv | |
{:git/url "https://github.com/athos/clj-skkserv.git" | |
:sha "fba7b099252e3fb376be019b495ddee5da0ecd28"} | |
org.apache.logging.log4j/log4j-core {:mvn/version "2.12.1"}} | |
:aliases {:start {:main-opts ["-m" "clj-skkserv.main" "--handler" "skkserv-example/handler"]}}} |