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
// C# : @kamiya_owl | |
using System; using System.Linq; class Haiku { static void Main() { var haiku = @" | |
み か ふ | |
ず わ る | |
の ず い | |
お と け |
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
def prime(src:Stream[Int]) : Stream[Int] = src.headOption match { | |
case None => Stream.empty | |
case Some(n) => n #:: prime(src.tail.filter(_ % n != 0)) | |
} | |
def prime() : Stream[Int] = prime(Stream.from(2,1)) | |
prime.take(10000).foreach(println) |
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
/** | |
* Created by kamiya on 2015/02/24. | |
* libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value | |
*/ | |
import scala.reflect.runtime.currentMirror | |
import scala.tools.reflect.ToolBox | |
object FizzBuzz { | |
class TraitCreator(name:String,const:String,superClass:String = "AnyRef") { | |
def make(n:Int = 1) : Stream[String] = |
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
"C:\Program Files\Java\jdk1.7.0_67\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:21948,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_67\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_67\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_67\jre\li |
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
def hoge(implicit str:String = "default", num:Int = 0) = println(str,num) | |
implicit val str2 = "implicit str2" | |
implicit val num2 = 123 | |
hoge()//(default,0) | |
hoge(str2,num2)//(implicit str2,123) | |
hoge(str2)//(implicit str2,0) | |
hoge(num = 456)//(default,456) | |
hoge(str = str2)//(implicit str2,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
def fizz (x:Int) : (Int, Boolean) = x match { case _ if x % 3 == 0 => (x,true) ; case _ => (x,false) } | |
def buzz (x:((Int, Boolean))) : (Int, Boolean, Boolean) = x._1 match { case n if n % 5 == 0 => (x._1, x._2,true) ; case _ => (x._1,x._2,false) } | |
def fizzbuzz(x:((Int,Boolean,Boolean))) : String = x match { | |
case (_, true, true) => "FizzBuzz" | |
case (_, true, false) => "Fizz" | |
case (_, false, true) => "Buzz" | |
case (n,_,_) => n.toString | |
} | |
implicit class FizzBuzz[A](self:A) { | |
def fizz(x:Any) = self |
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
/** | |
* Created by kamiya on 2015/02/16. | |
*/ | |
package kamiya.parse.brainfuck | |
import scala.util.parsing.combinator.RegexParsers | |
class BrainfuckProcessor { | |
private var pt : Int = 0 | |
private var buf : Array[Char] = Array.fill[Char](3000)(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
def Y[A,B]( f:((A => B), A ) => B, x:A ):B = f( (y:A) => Y(f,y),x) | |
((size:(Int,Int)) => Y( | |
(f:Map[(Int,Int),Boolean] => Stream[Map[(Int,Int),Boolean]], seed:Map[(Int,Int),Boolean]) => | |
((curr : Map[(Int,Int),Boolean]) => Stream.cons(curr,f(curr))) { | |
( for (x <- 0 to size._1; y <- 0 to size._2) yield List( | |
seed.get(x - 1, y - 1), seed.get(x, y - 1), seed.get(x + 1, y - 1), seed.get(x - 1, y), seed.get(x + 1, y), seed.get(x - 1, y + 1), seed.get(x, y + 1), seed.get(x + 1, y + 1)) | |
count { case Some(z) => z; case None => false } | |
match { case z if !seed(x, y) && z == 3 => (x, y) -> true ; case z if seed(x, y) && (z == 2 || z == 3) => (x, y) -> true ; case _ => (x, y) -> false } | |
).toMap }, | |
((s:(Int,Int)) => { for(x <- 0 to size._1 ; y <- 0 to size._2) yield (x,y) -> util.Random.nextBoolean }.toMap)(size) |
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
/** | |
* Created by kamiya on 2015/02/11. | |
*/ | |
import util.parsing.combinator._ | |
object Main { | |
class Expr | |
class Literal extends Expr | |
case class ConstNumber[+A](num: A) extends Literal |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication3 { | |
class Program { | |
static void Main(string[] args) { |