2017年4月3日月曜日

開発環境

Head First HTML5 Programming (Elisabeth Robson (著)、Eric Freeman (著)、O'Reilly Media)の Chapter 2.(Introducing JavaScript and the DOM: A Little Code)、Getting Expressive の EXERCISE(No. 1351) を Scheme で取り組んでみる。

EXERCISE(No. 1351)

コード(Emacs)

Scheme

(begin
  (load "./lib/stdlib/base.scm")
  (define res1 (+ (* (/ 9 5) 10) 32))
  (define res2 (string-append "Number" " " "2"))
  (define res3 (>= 5 5))
  (define res4 (not (string=? "blue" "pink")))
  (define pi (angle -1))
  (define res5 (* 2 pi 3))
  (define results (list (cons res1 50)                        
                        (cons res3 #t)
                        (cons res4 #t)))                        
  (for-each (lambda (pair)
              (display (car pair))
              (display ": ")
              (display (eqv? (car pair) (cdr pair)))
              (newline))
            results)
  (display res2)
  (display ": ")
  (display (string=? res2 "Number 2"))
  (newline)
  (display "π (angle -1): ")
  (display pi)
  (newline)
  (display res5)
  (newline)
  'done)

入出力結果(Terminal, REPL, ksi, ksc)

$ ./ksi < sample1.scm
> 50: #true
#true: #true
#true: #true
Number 2: #true
π (angle -1): 3.14159265358979323846264338327950
18.84955592153875943077586029967702
=> done
> $

0 コメント:

コメントを投稿