--eval
または-e
オプションで引数の式を評価できます。
式はシングルクォート(`
)で囲みます。
$ egison -e '(take 10 primes)'
{2 3 5 7 11 13 17 19 23 29}
;; map function | |
(define $map : [$A $B] ([(A -> B) {A}] -> {B}) | |
(lambda [$fn $xs] | |
(match xs (list something) | |
{[<nil> {}] | |
[<cons $x $rs> {(fn x) @(map fn rs)}]}))) | |
;; Ord type class | |
(type $Ordering {<Less> <Equal> <Greater>}) |
w3m -dump http://www.asahi-net.or.jp/~tk7m-ari/sazae_ichiran.html | \ | |
sed 's/(.*//g' | awk NF | awk '$0=$1" "$3' | sed -n '4,$p' | tr ' ' '\t' | \ | |
egison -T -F1s -s '(match-all-lambda | |
(list [string string])[ | |
<join _ <cons [$a $te1] | |
<cons [$b $te2] | |
<cons [$c ,te1] | |
<cons [$d ,te2]>>>> _> | |
[a b c d "=>" te1 te2 te1 te2] | |
])' | column -t |
# 形態素解析器を使うのでmecabを事前にインストールされたし | |
# % brew install mecab | |
# 青空文庫から「走れメロス」を取得 | |
$ w3m -dump http://www.aozora.gr.jp/cards/000035/files/1567_14913.html | \ | |
mecab | awk -F',' '$0=$1' | awk 'NF==2' | \ | |
egison -F1s -s '(match-all-lambda (list [string string])[<join _ <cons [$a ,"名詞"] <cons [$b ,"助詞"] <cons [$c ,"名詞"] <cons [$d ,"動詞"] <cons [$e ,"助動詞"]>>>>>> [a b c d e]])' | |
# Result | |
# ["メロス" "は" "激怒" "し" "た"] |
// Count paths from (0, 0) to (N, N) in the NxN lattice graph using DFS. | |
#include <iostream> | |
#include <sstream> | |
#include <vector> | |
using namespace std; | |
static unsigned long long cnt = 0; |
% egison -T -e '(maclaurin-expansion (cos x) x)'
1
0
(/ (* -1 x^2) 2)
0
(/ x^4 24)
0
(/ (* -1 x^6) 720)
0
; -*- mode: scheme;-*- | |
; Implementation of resolution principle for first-order logic in Egison | |
(define $unordered-pair | |
(lambda [$m] | |
(matcher | |
{[<pair $ $> [m m] {[[$x $y] {[x y] [y x]}]}] | |
[$ [something] {[$tgt {tgt}]}]}))) | |
(define $positive? |