This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defmacro metafb [forms] | |
| ;; ダサい。任意個のフォームを受け取れない | |
| (let [f0 (first forms) | |
| f1 (last forms) | |
| n0 (first f0) | |
| w0 (last f0) | |
| n1 (first f1) | |
| w1 (last f1) | |
| combined (list (* n0 n1) (str w0 w1)) | |
| comb-forms (sort #(compare (first %2) (first %1)) (cons combined forms)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns typed-clojure-sample.core | |
| (:require [clojure.core.typed :as t])) | |
| ;; 普通な感じの | |
| (t/ann number->currency [t/Int -> t/Str]) | |
| (defn number->currency [val] | |
| (-> val | |
| str | |
| (clojure.string/replace #"(?<=\d)(?=(\d\d\d)+(?!\d))" ","))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name hoge | |
| // @namespace http://hoge.co.jp/ | |
| // @include http://foo.com/* | |
| // @exclude | |
| // @author xorphitus | |
| // @description this script is a kind of hoge. | |
| // @version 0.0.1 | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pvcreate /dev/sda2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; http://sicp.iijlab.net/fulltext/x253.html | |
| ;; 2.5.3 例: 記号代数 | |
| ;; 代数式の操作はかなり面倒な話なので、どうやって扱うべきかここで考えてみる | |
| ;; と言っても、扱う代数式は簡単なものに限定するらしい | |
| ;; ガチでやるとなると、代数学の知識も、プログラムの複雑さもハンパないから、とのこと | |
| ;; オマイラの書くプログラムでは、具体的な値を操作していくけれど、 | |
| ;; それを抽象的な「代数(変数、記号)」のままで操作していくのは大変なわけで |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; http://sicp.iijlab.net/fulltext/x252.html | |
| ;; 2.5.2 異る型のデータの統合 | |
| ;; 有理数同士、複素数同士など、同じ型のものであれば演算できるようになったけれど、 | |
| ;; 有理数に複素数を足すような、異なる型同士の演算がまだできないから、できるようにする | |
| ;; これまで型毎に独立したコードになるように開発してきたので、 | |
| ;; 特定の型が別の型のことを知らなくてもいい状態を保って頑張りましょう |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;;; 2.3.4 例: Huffman符号化木 | |
| ;;; http://sicp.iijlab.net/fulltext/x234.html | |
| ;; 集合の要素を固定長のビット列で表すことはできるが空間効率が悪い | |
| ;; 可変長にすることによって短いデータで表せる | |
| ;; しかし可変長のデータは終端を知るためにどうするかが問題となる | |
| ;; モールス信号の場合は休止による分離符号を用いることで解決している |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define (cadr l) | |
| (car (cdr l))) | |
| ;;; 2.44 | |
| (define (up-split painter n) | |
| (if (= n 0) | |
| painter | |
| (let ((smaller (up-split painter (- n 1)))) | |
| (below painter (beside smaller smaller))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;----------------------- | |
| ;; WIP | |
| ;;----------------------- | |
| ;;; 2.34 | |
| (define (horner-eval x coefficient-sequence) | |
| (accumelate | |
| (lambda (this-coeff higher-terms) | |
| (+ this-coeff (* higher-terms x)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;----------------------- | |
| ;; WIP | |
| ;;----------------------- | |
| (define (cont-frac n d k) | |
| (define (itr i) | |
| ((if (> i k) | |
| 0 | |
| (/ (n i) (+ (d i) (itr (inc i)))) | |
| ))) |