ハイパーシェル芸クリエイター(※自称ではない)キュアエンジニア
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module EightPuzzle where | |
import Data.List (permutations) | |
-- 参考記事:https://mathtrain.jp/8puzzle | |
{-- | |
8 puzzle | |
1 2 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; -*- 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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Roughly based on https://github.com/Gabriel439/Haskell-Morte-Library/blob/master/src/Morte/Core.hs by Gabriel Gonzalez et al. | |
data Expr = Star | Box | Var Int | Lam Int Expr Expr | Pi Int Expr Expr | App Expr Expr deriving (Show, Eq) | |
subst v e (Var v') | v == v' = e | |
subst v e (Lam v' ta b ) | v == v' = Lam v' (subst v e ta) b | |
subst v e (Lam v' ta b ) = Lam v' (subst v e ta) (subst v e b ) | |
subst v e (Pi v' ta tb) | v == v' = Pi v' (subst v e ta) tb | |
subst v e (Pi v' ta tb) = Pi v' (subst v e ta) (subst v e tb) | |
subst v e (App f a ) = App (subst v e f ) (subst v e a ) |
% egison -T -e '(maclaurin-expansion (cos x) x)'
1
0
(/ (* -1 x^2) 2)
0
(/ x^4 24)
0
(/ (* -1 x^6) 720)
0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 形態素解析器を使うので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 | |
# ["メロス" "は" "激怒" "し" "た"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
- 2014/10/25 函数型なんたらの集い 2014 in Tokyo
- @gakuzzzz
- 中村 学
- 株式会社Tech to Value
- Scalaから来ました
NewerOlder