Skip to content

Instantly share code, notes, and snippets.

View omasanori's full-sized avatar

Masanori Ogino omasanori

View GitHub Profile
@omasanori
omasanori / prime_numbers.clj
Created September 30, 2011 03:00 — forked from mnzk/gist:1250574
Eratosthenes's infinite sieve
(defn- diff-seq
"Returns a lazy seq of numbers in s1 but not in s2.
Both of s1 and s2 must be increasing monotonically."
[s1 s2]
(when-let [x1 (first s1)]
(if-let [x2 (first s2)]
(cond
(= x1 x2) (recur (rest s1) (rest s2))
(> x1 x2) (recur s1 (drop-while (partial > x1) s2))
(< x1 x2) (let [[s11 s12] (split-with (partial > x2) s1)]
@omasanori
omasanori / make_number.clj
Created May 26, 2011 00:07 — forked from nyuichi/sisoku.clj
A library to make certain number from some numbers.
(ns
^{:author "OGINO Masanori"
:see-also [["http://www.cs.nott.ac.uk/~gmh/book.html" "Programming in Haskell"]]
:doc "A library to make certain number from some numbers.
This library solves a well-known problem called \"Ten Puzzle\" or \"Countdown
Problem\", but the target number is not limited to 10. You can get any integer
or rational number. Also, the number of source numbers is not limited to 4.
Note that source numbers are *not always* used once, but never or once.
@omasanori
omasanori / baton.clj
Created February 11, 2010 00:16 — forked from tnoborio/baton.clj
;; The First Edition Of Scheme Code Baton
;;
;; * What Is This?
;; This is a recreation that we pass Scheme codes as a baton and enjoy it
;; changed to something interesting.
;; Results are make public at Shibuya.lisp (event about Lisp held in Shibuya,
;; Japan).
;; We want code baton being a chance to write codes for beginner and to read
;; others codes for middles.
;;
;; 第1回 Scheme コードバトン
;;
;; ■ これは何か?
;; Scheme のコードをバトンのように回していき面白い物ができあがるのを楽しむ遊びです。
;; 次回 Shibuya.lisp で成果を発表します。
;; Scheme 初心者のコードを書くきっかけに、中級者には他人のコードを読む機会になればと思います。
;;
;; ■ 2 つのルール
;;
;; (1)自分がこれだと思える変更をコードに加えて2日以内に次の人にまわしてください。