macでracketを構築する
/
macでracketを構築する
# scheme(racket)のインストール
brew cask install racket
# 動作確認
racket -v
# 簡単なコードを実行
#lang racket
;; Print the Greek alphabet
(
for ([i (in-range 26)])
(display
(integer->char
(
+ i (char->integer #\a)
)
)
)
)
# ファイルを指定して実行
上記のコードをtest.rktで保存する
$ racket test.rkt
abcdefghijklmnopqrstuvwxyz
# ライブラリのインポート
(require ***)
# グラフの作成
sin(x)のグラフを作成する
#lang racket
;; y = sin(x)
(require plot)
(plot (function sin (- pi) pi #:label "y = sin(x)"))
3Dグラフを作成する
#lang racket
;; y = sin(x) plot
(require plot)
(plot3d (surface3d (λ (x y) (* (cos x) (sin y)))
(- pi) pi (- pi) pi)
#:title "An R × R → R function"
#:x-label "x" #:y-label "y" #:z-label "cos(x) sin(y)")
# まとめ
macでracketを構築しました.
# 参考サイト
macでscheme(racket)コンパイル環境を構築する (opens new window)