Skip to content

Instantly share code, notes, and snippets.

View egisatoshi's full-sized avatar

Satoshi Egi egisatoshi

View GitHub Profile
@egisatoshi
egisatoshi / IO from interpreter
Last active August 29, 2015 13:55
Easy access to IO from the prompt. This is a feature from Egison version 3.2.12
% egison
Egison Version 3.2.12 (C) 2011-2014 Satoshi Egi
http://www.egison.org
Welcome to Egison Interpreter!
> (io (each print (take 10 (map itos primes))))
2
3
5
7
11
user =
  { <User 1 "Egison_Lang">
    <User 2 "__Egi">
    ...
   }

follow =
  { <Follow 1 101 201>
    ...

Preparation

Build PLT files. (Get types of core libraries.) The file .dialyzer_plt is created in your home directory. It will take time (more than a minute).

$ dialyzer --build_plt --apps erts kernel stdlib crypto mnesia sasl common_test eunit
Last login: Mon May 12 19:57:49 on console
USER-no-iMac:~ user$ ruby --version
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
USER-no-iMac:~ user$ sudo gem install egison
Password:
Fetching: egison-0.0.2.gem (100%)
Successfully installed egison-0.0.2
Parsing documentation for egison-0.0.2
Installing ri documentation for egison-0.0.2
1 gem installed
@egisatoshi
egisatoshi / gist:b25a6207413d0e106bec
Last active August 29, 2015 14:03
range pattern
> (match-all (between 1 100) (set integer) [<cons (& ?(lte? 32 $) ?(lt? $ 64) $x) _> x])
{32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63}
> (car (match-all (between 1 100) (set integer) [<cons (& ?(lte? 32 $) ?(lt? $ 64) $x) _> x]))
32
@egisatoshi
egisatoshi / file0.txt
Created July 9, 2014 09:12
続編 - RubyにHaskellよりも強力なパターンマッチを実装した ref: http://qiita.com/egisatoshi/items/dfa13e45edbc71430048
require 'egison'
require 'prime'
include Egison
twin_primes = match_stream(Prime) {
with(List.(*_, _x, __("x + 2"), *_)) {
[x, x + 2]
}
}
@egisatoshi
egisatoshi / mod.egi
Created August 21, 2014 04:36
Module System of Egison (from version 3.4.0)
(module $Main
{
[String {string}] ; import only string
[$S [String {append concat}]] ; import only append and concat (with 'S.' as prefix)
[$S String] ; import all exported functions (with 'S.' as prefix)
}
{main} ; export main
)
(define $main
@egisatoshi
egisatoshi / Dockerfile
Created November 17, 2014 04:50
Dockerfile for Egison
FROM phusion/baseimage:latest
MAINTAINER Satoshi Egi
RUN apt-get update
RUN apt-get -y install libncurses-dev
RUN apt-get -y install haskell-platform
RUN cabal update
RUN cabal install egison
ENV PATH /root/.cabal/bin:$PATH
@egisatoshi
egisatoshi / Egison_command_tutorial_ja.md
Last active January 1, 2016 07:24
Egisonコマンドラインチュートリアル

Egisonコマンドラインチュートリアル

式を評価

--evalまたは-eオプションで引数の式を評価できます。 式はシングルクォート(`)で囲みます。

$ egison -e '(take 10 primes)'
{2 3 5 7 11 13 17 19 23 29}
@egisatoshi
egisatoshi / old_egison_wiki.md
Last active August 29, 2015 14:12
old wiki (内容が古くなったので移動)

Welcome to the egison wiki!

How to start Development

Checkout Egison

$ git clone https://github.com/egisatoshi/egison.git