Comment detail

与えられた文字列でピラミッド (Nested Flatten)

This comment is reply for 2583 rubikitch: Scheme用SLIMEがあればいいのに…(与えられた文字列でピラミッド). Go to thread root.

文字列のインデックスアクセスも算術演算も明示的ループも無しで。
1
2
3
4
5
6
(use util.list)
(define (pyramid s)
  (let r ((s (string->list s)) (p '()))
    (unless (null? s)
      (r (cdr s) (cons #\ p))
      (apply print (append p (intersperse #\  s))))))
名前付きletは明示的loopじゃないと?:)
名前付けてるだけだも〜ん。 それにいわゆる「ループとしての使いかた」はしてないし。
Never mind ! :)

Index

Feed

Other

Link

Pathtraq

loading...