Skip to content

Instantly share code, notes, and snippets.

Yoshinori Kohyama kohyama

Block or report user

Report or block kohyama

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View barnsleys_fern.clj
(ns barnsleys-fern)
(defn- affine [a b]
(fn [x] (map #(apply + (conj (map * %1 x) %2)) a b)))
(defn- move [x]
(let [afs (mapv (partial apply affine)
[[[[ 0.0 0.0 ] [ 0.0 0.16]] [0.0 0.0 ]]
[[[ 0.85 0.04] [-0.04 0.85]] [0.0 1.6 ]]
[[[ 0.2 -0.26] [ 0.23 0.22]] [0.0 1.6 ]]
kohyama / subseqseq.clj
Last active Oct 6, 2015
Divide a sequence into continuous subsequences
View subseqseq.clj
(def sss
(fn [s]
(let [n (count s)]
(zero? n) '(())
(= n 1) `((~s))
:else (mapcat
(fn [c]
(let [[a b] (split-at c s)]
kohyama / factorize.clj
Last active Mar 31, 2019
Prime Factorization in Clojure
View factorize.clj
(defn factorize [n]
((fn f [n [h & r :as ps]]
(cond (< n 2) '()
(zero? (mod n h)) (cons h (lazy-seq (f (quot n h) ps)))
:else (recur n r)))
n prime-numbers)))
kohyama / primes.clj
Created Sep 28, 2015
Prime numbers in Clojure
View primes.clj
(def prime-numbers
((fn f [x]
(cons x
(f (first
(fn [n]
(some #(zero? (mod n %))
(take-while #(<= (* % %) n) prime-numbers)))
(iterate inc (inc x))))))))
kohyama / project.clj
Last active Sep 18, 2015
I can't execute a standalone jar using lighttable.nrepl.handler/lighttable-ops.
View project.clj
(defproject nltry "0.1"
:dependencies [
[org.clojure/clojure "1.7.0"]
[org.clojure/tools.nrepl "0.2.11"]
[lein-light-nrepl "0.1.3"]
:aot :all
:main nltry.core
:repl-options {:nrepl-middleware [lighttable.nrepl.handler/lighttable-ops]}
kohyama / fibbuzz.clj
Last active Aug 29, 2015
FibBuzz in Clojure
View fibbuzz.clj
(defn fibs [a b] (cons a (lazy-seq (fibs b (+' a b)))))
(defn fizzbuzz [x]
(condp #(zero? (mod %2 %1)) x
15 "FizzBuzz"
5 "Buzz"
3 "Fizz"
(def fibbuzz-seq (map fizzbuzz (fibs 1 1)))
kohyama / sorts.clj
Last active Aug 29, 2015
Sort algorithms in Clojure
View sorts.clj
(defn insertion-sort [ks]
(reduce (fn [a x]
(let [[h t] (split-with #(< % x) a)]
(concat h [x] t)))
[] ks))
(defn merge-sort [ks]
(let [c (count ks)]
(if (= c 1) ks
((fn m [[[ah & ar :as a] [bh & br :as b]]]
kohyama / file1.txt
Created Mar 7, 2014
Ntmux を用いたマルチリンガル開発 ref:
View file1.txt
% ntmux 5000 irb
kohyama / foo.clj
Last active Dec 24, 2015
How to generalize these three functions.
View foo.clj
(ns foo
(:require [clojure.test :refer (with-test is are run-tests)]))
(defn flatten-map [m kf vf]
(into {}
((fn g [kv n]
(if (map? n)
(apply concat
(keep (fn [[k v]] (g (conj kv k) v)) n))
kohyama /
Last active Dec 22, 2015
An example client code to binary-communicate with a TCP server / TCP サーバとバイナリ通信するクライアントコード例


An example client code to binary-communicate with a TCP server.

TCP サーバとバイナリ通信するクライアントコードの例です.

Usage / 使い方

Give informations of a TCP server to the first argument as a map. :host is a string representing an IP address or a hostname which can be forward-looked up and :port is an integer represents a port.

You can’t perform that action at this time.