This file contains hidden or 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
| +++++++++[>++++++++<-]>. |
This file contains hidden or 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
| ;MOVfuscator | |
| ;domas 2015 | |
| USE32 | |
| section .data | |
| DATA equ 131072 | |
| %macro c_s 1 | |
| %1: dd 0 |
This file contains hidden or 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
| def pn(str: String): Double = pnPrime(str.split(" ").toList)._1 | |
| // 一意型パターン | |
| def pnPrime(src: List[String]): (Double, List[String]) = src match { | |
| case "+"::xs => { | |
| val (a, n1) = pnPrime(xs) | |
| val (b, n2) = pnPrime(n1) | |
| (a.toInt + b, n2) | |
| } | |
| case "-"::xs => { |
This file contains hidden or 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
| def ifn(str: String): Int = expr(str.split(" ").toList)._1 | |
| // expr := term ["+"|"-" term]* | |
| def expr(src: List[String]): (Int, List[String]) = { | |
| //println(s"[expr] src: $src") | |
| val (v1, src2) = term(src) | |
| def expr2(v1: Int, src: List[String]): (Int, List[String]) = src match { | |
| case "+"::src3 => { | |
| val (v2, src4) = term(src3) | |
| expr2(v1 + v2, src4) |
This file contains hidden or 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
| def ifn(str: String): Int = expr(str.split(" ").toList)._1 | |
| // expr := term ["+"|"-" expr] | |
| def expr(src: List[String]): (Int, List[String]) = { | |
| //println(s"[expr] src: $src") | |
| val (v1, src2) = term(src) | |
| src2 match { | |
| case "+"::src3 => { | |
| val (v2, src4) = expr(src3) | |
| (v1 + v2, src4) |
This file contains hidden or 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
| // スタックにすべて積んで、List("1", "+", "2")みたいな感じになったら、演算する | |
| def ifn(str: String): Int = ifnPrime(str.split(" ").toList, Nil) | |
| def ifnPrime(str: List[String], stack: List[String]): Int = (str, stack) match { | |
| case ("+"::t, xs) => ifnPrime(t, xs :+ "+") | |
| case ( n::t, zs) => { | |
| val list = zs :+ n | |
| list match { | |
| case (x::op::y) if op == "+" => ifnPrime(t, List((x.toInt + y.head.toInt).toString)) | |
| case x => ifnPrime(t, x) |
This file contains hidden or 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
| // スタックにすべて積んで、List("1", "+", "2")みたいな感じになったら、演算する | |
| def ifn(str: String): Int = ifnPrime(str.split(" ").toList, Nil) | |
| def ifnPrime(str: List[String], stack: List[Int]): Int = { | |
| println(s"str: $str stack: $stack") | |
| (str, stack) match { | |
| case ("+"::t, x::xs) => x + ifnPrime(t, Nil) | |
| case ( n::t, _ ) => ifnPrime(t, n.toInt::stack) | |
| case _ => stack.head | |
| } |
This file contains hidden or 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
| import Data.List.Split | |
| import Control.Monad.State | |
| rpn str = rpnPrime (splitOn " " str) [] | |
| rpnPrime ("+":t) (y:x:zs) = rpnPrime t $ x + y:zs | |
| rpnPrime (n:t) zs = rpnPrime t $ read n:zs | |
| rpnPrime [] [x] = x | |
| rpnM str = evalState (rpnPrimeM $ splitOn " " str) [] |
This file contains hidden or 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
| import Data.List.Split | |
| rpn str = rpnPrime (splitOn " " str) [] | |
| rpnPrime ("+":t) (y:x:zs) = rpnPrime t $ x + y:zs | |
| rpnPrime (n:t) zs = rpnPrime t $ read n:zs | |
| rpnPrime _ (x:xs) = x | |
| main = do | |
| print $ rpn "1" |
This file contains hidden or 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
| import Data.List.Split | |
| import Control.Monad.State | |
| -- 状態は引数としては明示的に書かない | |
| pn str = fst $ pnPrime $ splitOn " " str | |
| pnPrime ("+":s0) = | |
| let (a, s1) = pnPrime s0 | |
| (b, s2) = pnPrime s1 | |
| in (a + b, s2) | |
| pnPrime (x:xs) = ((read x:: Int), xs) |