Egison のインストール方法 (Packages)
Linux ユーザーは、yum
または dpkg
を使って簡単にEgisonをインストールできます。
$ sudo yum install https://git.io/egison.x86_64.rpm https://git.io/egison-tutorial.x86_64.rpm
$ wget https://git.io/egison.x86_64.deb https://git.io/egison-tutorial.x86_64.deb
$ sudo dpkg -i ./egison*.deb
Egison のインストール方法 (Haskell Platform)
1. Haskell Platform をインストール
Egison をインストールするには Haskell Platform を先にインストールする必要があります。 その理由は Hackage という Haskell のパッケージシステムを用いて Egison が配布されているためです。
Linux ユーザはそのディストリビューションのパッケージシステムを使って Haksell Platform をインストールできます。
以下は、apt-get
コマンドによりインストールする例です。
% sudo apt-get update
% sudo apt-get install haskell-platform libncurses5-dev
2. Hackage から Egison をインストール
Haskell Platform をインストールしたら、ターミナルから以下のコマンドで Egison をインストールできます。
% cabal update
% cabal install egison egison-tutorial
...
Installing executable(s) in /home/xxx/.cabal/bin
Registering egison-X.X.X...
3. PATH の設定
Egison にインストールに成功したら、出力結果にどこにEgisonの実行ファイルが作られたか出力されているはずです。
シェルが egison
コマンドを呼び出せるようにするために、$PATH
変数の設定をしましょう。
bash の場合、以下のように$PATH
変数の設定ができます。
% echo "PATH=\$PATH:/home/xxx/.cabal/bin" >> ~/.bashrc
% source ~/.bashrc
Egison の始め方
インストールに成功すると、egison
コマンドで Egison のインタプリタを起動できるようになります。
インタプリタを止めるには Control-D
を押してください。
% egison
Egison Version X.X.X (C) 2011-2014 Satoshi Egi
http://www.egison.org
Welcome to Egison Interpreter!
> ^D
Leaving Egison Interpreter.
egison-tutorial
コマンドも使えるようになります。
チュートリアルを止めるには Control-D
を押してください。
このチュートリアルは Egison に初めて触れるひとのためのチュートリアルです。
ぜひ最初に試してみてください。
% egison-tutorial
Egison Tutorial for Version X.X.X (C) 2013-2014 Satoshi Egi
http://www.egison.org
Welcome to Egison Tutorial!
==============================
List of sections in the tutorial
1: Calculate numbers
2: Basics of functional programming
3: Define your own functions
4: Basic of pattern-matching
5: Pattern-matching against infinite collections
6: Writing scripts in Egison
==============================
Choose a section to learn.
(1-6): 5
====================
We can write a pattern-matching against infinite lists even if that has infinite results.
Note that Egison really enumerate all pairs of two natural numbers in the following example.
Examples:
(take 10 (match-all nats (set integer) [> [m n]]))
====================
>