円を作ってみた
(define (make-circle radius) (let rows ((r 0) (row '())) (if (= r (+ (* 2 radius) 1)) (reverse row) (rows (+ r 1) (cons (let columns ((c 0) (col '())) (if (= c (+ (* 2 radius) 1)) (reverse col) (columns (+ c 1) (cons (if (> (magnitude (make-rectangular (- r radius) (- c radius))) radius) #\space #\+) col)))) row))))) (define (print-circle circle) (for-each (lambda (row) (print (list->string row))) circle)) gosh> (print-circle (make-circle 10))
実行例
+
+++++++++
+++++++++++++
+++++++++++++++
+++++++++++++++++
+++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
- +
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++
+++++++++++++++++
+++++++++++++++
+++++++++++++
+++++++++
+
追記
puts lambda{|r|(-r..r).map{|x|(-r..r).map{|y|(x*x+y*y>r*r)?" ":"+"}.join + "\n"}}[10]