Skip to content

Instantly share code, notes, and snippets.

@kohyama
kohyama / incanter-interns.md
Last active April 3, 2017 14:01
Incanter の関数・マクロまとめ

incanter.core

与えられた数について

factorial: 階乗 (引数は非負整数)
gamma: ガンマ関数 (階乗の拡張. 引数 n が 1以上の整数ならば, n - 1 の階乗に等しい)

与えられたシーケンスについて

sum: 総和
sum-of-squares: 平方の総和
prod: 総積

@kohyama
kohyama / .vimrc
Last active December 21, 2015 16:29
To set filetype features of slimv on/off individually.
" part of my .vimrc
" -- neobundle
set nocompatible
filetype off
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim
call neobundle#rc(expand('~/.vim/bundle'))
endif
set shell=/bin/sh
@kohyama
kohyama / README.md
Last active March 3, 2018 20:44
Example to operate DOM in ClojureScript via Browser REPL
@kohyama
kohyama / README.md
Last active December 20, 2015 20:38
How to use browser REPL of ClojureScript with compojure

How to use browser REPL of ClojureScript with compojure

You can do this without compojure. Refer [A minimum setting to use browser REPL of ClojureScript] (https://gist.github.com/kohyama/6183122).

Assumed that you have set leiningen up and can use it.

1. Prepare files

Copy project.clj, repl-test.cljs, minimum_httpd.clj

@kohyama
kohyama / README.md
Last active February 6, 2021 12:41
A minimum setting to use browser REPL of ClojureScript

A minimum setting to use browser REPL of ClojureScript

Assumed that you have set leiningen up and can use it.

1. Prepare files

Copy project.clj, repl-test.cljs and brepl-test.html from this gist or git clone this gist and move or copy repl-test.cljs under src directory.

$ git clone https://gist.github.com/6183122.git
$ cd 6183122/
@kohyama
kohyama / mapf.clj
Last active December 20, 2015 06:59
マップの最下層の値達に他の引数と共に関数を適用する. Apply a function to values in lowest levels of a map with other arguments
(require '[clojure.test :refer (with-test is run-tests)])
(with-test
(defn mapf [f m & args]
((fn g [n]
(if (map? n)
(into {} (map (fn [[k v]] [k (g v)]) n))
(apply f n args)))
m))
@kohyama
kohyama / stm.md
Last active February 9, 2023 05:35
Clojure ref, atom, agent の要約
@kohyama
kohyama / clojure-exercises.md
Last active October 19, 2017 08:54
Clojure Exercises / Clojure 演習
@kohyama
kohyama / nq.clj
Last active October 19, 2017 06:12
N クイーン問題を Clojure で解きます Solve N-Queen problems
(require '[clojure.test :refer (with-test is run-tests)])
(with-test
(defn- trns "盤を転置します"
[b] (vec (apply (partial map vector) b)))
; テスト
(is (= (trns [[:a :b]
[:c :d]])
[[:a :c]
@kohyama
kohyama / eeos.md
Last active October 23, 2017 02:41
外部から文字列で与えた式を, 内部に出て来る変数を実行時に決まる値で束縛した状態で評価したい. I want evaluate a expression which comes from outside as a string with some variables binded to values determined at runtime.
(def s "(- a b)"))

のような文字列があるとき, 実行時に決まる値で a や b を束縛して, この式を評価したいとする.

(let [a 4 b 3] (eval (read-string s)))