計算機プログラムの構造と解釈 第二版 P59 問題2.23

・リストを左から順に手続きを作用させる手続きfor-eachをつくる。


そんな説明が必要なほど難しくはないと俺は感じているのである。
carして、実行して、cdrしたやつを、次の回にまわしてやるみたいな感じ。


はい実装

#!/usr/local/bin/gosh
;; -*- coding: utf-8 -*-

(use ggc.debug.trace)
(use math.mt-random)

(define nil '())


(define (for-each f items)
  (cond ((null? items) nil)
        (else (f (car items))
              (for-each f (cdr items)))))

;; main
(define (main args)

  (for-each (lambda (x) (newline) (display x)) (list 57 321 88))

 0)


実行

57
321
88


まぁ。こんな感じで。