author: @deltam
Colojure用DBアクセスライブラリ、Kormaの検索系機能の紹介とリレーション機能の実験。
Korma 0.3.0-beta11
<?php | |
require 'stream.php'; | |
/** SICP3.5.2 無限ストリーム */ | |
function integers_start_from($n) | |
{ | |
return cons_stream($n, function() use ($n) {return integers_start_from($n + 1);}); | |
} | |
$integers = integers_start_from(1); | |
echo "integers\n"; |
;;; Usage: clj decode.clj prime.txt > decss.c.gz | |
;;; gunzip decss.c.gz | |
(def src (slurp (first *command-line-args*))) | |
(def illegal-prime (bigint (.replaceAll src "[^0-9]" ""))) | |
(def prime-bytes (.toByteArray (.toBigInteger illegal-prime))) | |
(def stdout (.getChannel (java.io.FileOutputStream. java.io.FileDescriptor/out))) | |
(.write stdout (java.nio.ByteBuffer/wrap prime-bytes)) |
user=> (def my-name (.toByteArray (BigInteger. "7234307623547114003"))) | |
#'user/my-name | |
user=> (-> (java.io.FileOutputStream. "name.txt") .getChannel (.write (java.nio.ByteBuffer/wrap my-name))) | |
8 | |
; Ctrl-D | |
; $ cat name.txt | |
; deltam |
<html> | |
<!-- forのかわりにhogeを使う --> | |
<script id="hoge" type="text/oreore-javascript"> | |
hoge(var i=0; i<10; i++) | |
console.log(i); | |
</script> | |
<script type="text/javascript"> | |
var script=document.getElementById('hoge'); |
<?php | |
/** | |
* 「ビューティフル・コード」(P.91)で、普通のプログラマは二分探索をまともに書けないと煽られたので書いた。 | |
*/ | |
function search($needle,$haystack) | |
{ | |
$start=0; | |
$end=count($haystack); | |
do |
author: @deltam
Colojure用DBアクセスライブラリ、Kormaの検索系機能の紹介とリレーション機能の実験。
Korma 0.3.0-beta11
; 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)) |
(ns overtone-chrismas.core | |
(:use [overtone.live])) | |
(defn foo [freq] | |
(pan2 (sin-osc freq))) | |
; ドレミの周波数を定義 | |
(def doremi {:none 0 | |
:do 261.6 | |
:re 293.6 |
(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])) | |
; 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))))) |