mokeheheのScheme日記

ツッコミ、添削大歓迎です。いろいろ教えてください。

2007-11-24

[] LEDcounter

anarchy golf - LED counterを解く

(use srfi-1)

; LEDデータ
(define LEDData
  '((" _ "
     "| |"
     "|_|")
    ("   "
     "  |"
     "  |")
    (" _ "
     " _|"
     "|_ ")
    (" _ "
     " _|"
     " _|")
    ("   "
     "|_|"
     "  |")
    (" _ "
     "|_ "
     " _|")
    (" _ "
     "|_ "
     "|_|")
    (" _ "
     "  |"
     "  |")
    (" _ "
     "|_|"
     "|_|")
    (" _ "
     "|_|"
     "  |")
    (" _ "
     "|_|"
     "| |")
    ("   "
     "|_ "
     "|_|")
    (" _ "
     "|  "
     "|_ ")
    ("   "
     " _|"
     "|_|")
    (" _ "
     "|_ "
     "|_ ")
    (" _ "
     "|_ "
     "|  ")))

; 数値を2桁の16進数で出力
(define (print-LED2 i)
        (for-each print
                  (ref LEDData (quotient i 16))
                  (ref LEDData (remainder i 16))))

; エントリ
(dotimes (x 256)
  (print-LED2 x))
トラックバック - http://sicp.g.hatena.ne.jp/mokehehe/20071124