Skip to content

Instantly share code, notes, and snippets.

(ns intro-seq.core
(:use [clojure.contrib seq]))
;; Clojure初心者向けに覚えておくと便利なシーケンス操作関数の使用例を列挙する
;; 1.2でclojure.coreに移動し、廃止予定(DEPRECATED.)になってるのもある
;; 全部で18個(DEPRECATEDは8個)
;; 使用頻度高そう系(4個)
;; c.c.combinatorics/subsetsを使って、べき集合(Powerset)を作る
(use '[clojure.contrib.combinatorics :only (subsets)])
(subsets '())
;(())
(subsets '(1))
;(() (1))
;; fill-queue による非同期フックの実験
;; 指定したファイルの最終更新日時が変わったらキューにそのファイル名をプッシュする
(ns watch-file-status
(:use [clojure.contrib.seq :only (fill-queue)])
(:import [java.io File]
[java.util Date]
[java.text SimpleDateFormat]))
@deltam
deltam / index.html
Created May 8, 2011 05:17
映画『ウォッチメン』のロールシャッハ仮面を作れないか実験中
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Rorschach Mask</title>
<script type="text/javascript" src="rorschach.js"></script>
</head>
<body>
<div align="center"><b>Rorschach Mask</b></div>
@deltam
deltam / FizzBuzz.clj
Created November 14, 2011 13:03
FizzBuzz on Clojure
(println
(map #(cond (zero? (mod % (* 3 5))) "FizzBuzz"
(zero? (mod % 3)) "Fizz"
(zero? (mod % 5)) "Buzz"
:else %)
(range 1 101)))
@deltam
deltam / gist:1454748
Created December 10, 2011 07:01
Clojureでクリスマスソングを書こう
(ns overtone-chrismas.core
(:use [overtone.live]))
; example/basic.cljからコピペ
(defsynth foo [freq 200 dur 0.5]
(let [src (saw [freq (* freq 1.01) (* 0.99 freq)])
low (sin-osc (/ freq 2))
filt (lpf src (line:kr (* 10 freq) freq 10))
env (env-gen (perc 0.1 dur) :action FREE)]
(out 0 (pan2 (* 0.1 low env filt)))))
(defproject overtone-chrismas "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.3.0"]
[overtone "0.5.0"]])
(ns overtone-chrismas.core
(:use [overtone.live]))
(defn foo [freq]
(pan2 (sin-osc freq)))
; ドレミの周波数を定義
(def doremi {:none 0
:do 261.6
:re 293.6
@deltam
deltam / test.zzz
Created May 3, 2012 09:10
1 + 1 on zozotez http://code.google.com/p/zozotez/ #残パン会
; print 1 + 1
; usage: ./zozotez test.zzz
(p
(? (: 'sum (\ (x y) (? x (sum (d x) (c (a x) y)) y)))
(? (: 'leq (\ (x y) (? x (? y (leq (d x) (d y)) NIL) (? y NIL T))))
(? (: 'find (\ (x n) (? (leq x (e (a n))) (a n) (? n (find x (d n)) NIL))))
(? (: '1 '(a))
(? (: '2 '(a a))
(? (: '3 '(a a a))
(? (: '4 '(a a a a))