Skip to content

Instantly share code, notes, and snippets.

View egisatoshi's full-sized avatar

Satoshi Egi egisatoshi

View GitHub Profile
@egisatoshi
egisatoshi / Set
Last active October 10, 2015 07:18
Set cons of Egison from version 2.4.2
> (test (match-all {0 1} (Set Integer)
[<cons $a_1 <cons $a_2 <cons $a_3 _>>>
{a_1 a_2 a_3}]))
{{0 0 0} {0 0 1} {0 1 0} {0 1 1} {1 0 0} {1 0 1} {1 1 0} {1 1 1}}
@egisatoshi
egisatoshi / execute mine.egi
Created July 20, 2012 08:17
icfpc2012 simulator in Egison2.3.3
% cd sample/icfpc2012/
% egisonc mine.egi
[1 of 1] Compiling Main ( _tmp.hs, _tmp.o )
Linking mine ...
% ./mine maps/contest1.map
######
#. *R#
# \.#
#\ * #
L .\#
@egisatoshi
egisatoshi / poker-hands.egi
Created July 17, 2012 14:37
Poker Hands in Egison
(define $poker-hands
(lambda [$Cs]
(match Cs (Multiset Card)
{[<cons <card $S $n>
<cons <card ,S ,(- n 1)>
<cons <card ,S ,(- n 2)>
<cons <card ,S ,(- n 3)>
<cons <card ,S ,(- n 4)>
!<nil>>>>>>
<straight-flush>]
@egisatoshi
egisatoshi / Multiset.egi
Created July 17, 2012 14:09
Multiset Definition in Egison 2.3
(define $Multiset
(lambda [$a]
(type
{[,$val []
{[$tgt (match [val tgt] [(Multiset a) (Multiset a)]
{[[<nil> <nil>] {[]}]
[[<cons $x $xs> <cons ,x ,xs>] {[]}]
[[_ _] {}]})]}]
[<nil> []
{[{} {[]}]