gaucheでマージソート. きちんとテストも書いてみた. sort-merge.scm ;; merge-sort (use srfi-1) (define (merge-sort l) (let ((len (length l))) (cond [(>= len 2) (merge (merge-sort (former l)) (merge-sort (latter l)))] [else l] ))) (define (merge l1 l2) (cond [(null? l1) l2] [(null? l2) l1] [(< (car l1) (car l2)) (cons (car l1) (merge (cdr l1) l2))] [else (cons (car l2) (merge l1 (cdr l2)))] )) ;; the former part of the l