消えてなくなれよ >オブジェクト指向 at TECH
[2ch|▼Menu]
433:デフォルトの名無しさん
09/03/07 18:33:13
>>415
(define (oremove o l)
(if (pair? l)
(if (eq? o (car l))
(cdr l)
(cons (car l) (oremove o (cdr l))))
l))
(define (perm s)
(define n 0)
(define (perml f l y)
(if (pair? l)
(for-each (lambda(x) (perml f (oremove x l) (cons x y))) l)
(f (reverse y))))
(perml (lambda (y) (display (list->string y)) (newline) (set! n (+ n 1))) (string->list s) '())
n)

(perm "123456789")
123456789
123456798

987654312
987654321
=>362880

(* 1 2 3 4 5 6 7 8 9)
=>362880


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5505日前に更新/139 KB
担当:undef