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
| using Sprache; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace lambda_calc | |
| { | |
| abstract class Statement { } | |
| abstract class Expr : Statement |
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
| using OpenTK; | |
| using OpenTK.Audio.OpenAL; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication4 { | |
| class Program { |
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
| object Main { | |
| implicit class Point[T <% Double](val self:(T,T)) { | |
| lazy val abs = math.sqrt(self._1 * self._1 + self._2 * self._2) | |
| def -[U <% Double](p:(U,U)) = (self._1 - p._1, self._2 - p._2) | |
| def cross[U <% Double](p:(U,U)) = self._1 * p._2 - self._2 * p._1 | |
| } | |
| def crossProduct[T <% Double](polygon:List[(T,T)],points:List[(T,T)]) : List[List[Double]] = | |
| points.map { p => polygon zip(polygon.tail :+ polygon.head) map{ case(a,b) => (a - p) cross (b - p)} } | |
| def isCrossVector(xs:List[Double]) : Boolean = xs.forall(_ > 0) || xs.forall(_ < 0) | |
| def isCross[T <% Double](poly1:List[(T,T)],poly2:List[(T,T)]) : Boolean = |
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 scala.collection.immutable.Stack | |
| object Main { | |
| def binOp(q:Stack[Double])(f:(Double,Double) => Double) : Stack[Double] = { | |
| val (b,q2) = q.pop2 | |
| val (a,q3) = q2.pop2 | |
| q3.push(f(a,b)) | |
| } | |
| def unaryOp(q:Stack[Double])(f:(Double) => Double) : Stack[Double] = { | |
| val (a,q2) = q.pop2 |
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
| println(((s:String) => s.drop(5 + 7).take(5).zip(s.drop(5).take(7)).zip(s.take(5)).map{case ((a,b),c) => s"$a $b $c"}.++(s.drop(5 + 5).take(2).map{x => s" $x"}).mkString("\r\n"))("なかぬならなかせてみようホトトギス")) |
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
| // C# : @kamiya_owl | |
| using System; using System.Linq; class Haiku { static void Main() { var haiku = @" | |
| み か ふ | |
| ず わ る | |
| の ず い | |
| お と け |
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 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 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
| /** | |
| * 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 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
| "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 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 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) |