Skip to content

Instantly share code, notes, and snippets.

;; 第1回 Scheme コードバトン
;;
;; ■ これは何か?
;; Scheme のコードをバトンのように回していき面白い物ができあがるのを楽しむ遊びです。
;; 次回 Shibuya.lisp で成果を発表します。
;; Scheme 初心者のコードを書くきっかけに、中級者には他人のコードを読む機会になればと思います。
;;
;; ■ 2 つのルール
;;
;; (1)自分がこれだと思える変更をコードに加えて2日以内に次の人にまわしてください。
;; 第1回 Scheme コードバトン
;;
;; ■ これは何か?
;; Scheme のコードをバトンのように回していき面白い物ができあがるのを楽しむ遊びです。
;; 次回 Shibuya.lisp で成果を発表します。
;; Scheme 初心者のコードを書くきっかけに、中級者には他人のコードを読む機会になればと思います。
;;
;; ■ 2 つのルール
;;
;; (1)自分がこれだと思える変更をコードに加えて2日以内に次の人にまわしてください。
#!/opt/local/bin/sbcl --script
;; 2009-10-06
;; カプレカー操作の検算
;; 4桁の場合
(defparameter *num-keta* 4)
;;; リストをその並びの十進数に変換する
(defun list-to-dig (lst)
(reduce #'(lambda (a b) (+ (* a 10) b)) lst))
digraph g{ graph[rankdir=LR;];
v0477 [label="0477\n(33)"]
v0225 [label="0225\n(05)"]
v4689 [label="4689\n(25)"]
v1224 [label="1224\n(03)"]
v2268 [label="2268\n(44)"]
v6678 [label="6678\n(12)"]
v6777 [label="6777\n(01)"]
v5589 [label="5589\n(34)"]
v2889 [label="2889\n(04)"]
/* find loops in kaprekar's operation sequence
* written by deltam@gmail.com
* USAGE: kaprekar <digit>
*/
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
; Googleグループ clojure-ja
; 質問: 関数型プログラミングでいうZip関数をClojureではどう書く?
; <http://groups.google.com/group/clojure-ja/browse_thread/thread/98cc4e3b7bcb4a28#>
; それぞれREPL実行結果まとめ
(def a [1 2 3 4])
(def b [5 6 7 8])
; はやみずさんのアイデア
(ns mathew12
(:use [clojure.contrib.seq-utils :only (includes? indexed)]))
(def m12 [0 1 2 3 4 5 6 7 8 9 10 11])
; 実験
(comment
(map (fn [m i] (vector m i)) m12 (vec (range 0 11)))
(indexed m12)
<html>
<title>10分で書くベイジアンフィルタ</title>
<script type="text/javascript">
<!--//
function run() {
var hash = splitWord(form.classA.value);
var str = "";
var sum = 0;
for (key in hash) {
str += key + ": " + hash[key] + ";¥n";
; int-calc.clj
(ns int-calc
(:use [clojure.contrib.command-line :only (with-command-line)]))
(with-command-line *command-line-args*
"clj int-calc.clj [-p|-mi|-ml] [-modulo n] nums.."
[[plus? p? "plus" true]
[minus? mi? "minus"]
[multiply? ml? "multiply"]
[modulo "mod n"]
;; 順列生成アルゴリズム
;; 『群論の味わい』p.69より
(ns steinhaus
(:use [clojure.contrib.seq :only (rec-cat)]))
(defn- insert-at [item n coll]
(concat (take n coll) (vector item) (drop n coll)))
(defn stein-rec [max]