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
import scala.util.parsing.combinator.JavaTokenParsers | |
object Test extends App with ExprParsers2 { | |
println(eval(parseAll(expr, "1+1-2*3").get)) | |
} | |
trait ExprParsers1 extends JavaTokenParsers { |
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
import java.awt.Dimension | |
import java.awt.event.MouseAdapter | |
import java.awt.event.MouseEvent | |
import javax.swing.JFrame | |
import scala.collection.immutable | |
import scala.concurrent.duration._ | |
import akka.actor._ | |
import akka.stream._ |
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
import scala.io.StdIn | |
import scala.util._ | |
import akka.actor._ | |
import akka.stream._ | |
import akka.stream.scaladsl._ | |
import akka.stream.stage._ | |
import akka.util._ | |
object ComplexTcpClient extends App { |
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
import scala.io.StdIn | |
import scala.util._ | |
import akka.actor._ | |
import akka.stream._ | |
import akka.stream.scaladsl._ | |
import akka.stream.stage._ | |
import akka.util._ | |
object SimpleTcpClient extends App { |
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
import scala.util._ | |
import akka.actor._ | |
import akka.stream._ | |
import akka.stream.scaladsl._ | |
import akka.util._ | |
object SimpleTcpServer extends App { | |
val address = "127.0.0.1" |
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
Scala 2.9 | |
keywords (39): | |
abstract case catch class def do else extends false final finally for forSome if implicit import lazy match new null object override package private protected return sealed super this throw trait try true type val var while with yield | |
symbols (12): | |
_ : = => <- <: <% >: # @ | |
⇒ (Unicode \u21D2) same as: => | |
← (Unicode \u2190) same as: <- |
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
object Test extends App { | |
new Interpreter("++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.") | |
} | |
class Interpreter(str: String) { | |
val prog = """[^\+\-\<\>\.\,\[\]]""".r replaceAllIn (str, "") | |
val openBrackets = findBraces(0, Nil, Map.empty) | |
val closeBrackets = openBrackets map { _.swap } | |
exec() |
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
% mvn -X scalastyle:check :( | |
Apache Maven 3.0.5 (rNON-CANONICAL_2013-02-25_10-23_root; 2013-02-25 11:23:59+0100) | |
Maven home: /opt/maven | |
Java version: 1.6.0_27, vendor: Sun Microsystems Inc. | |
Java home: /usr/lib/jvm/java-6-openjdk/jre | |
Default locale: en_US, platform encoding: UTF-8 | |
OS name: "linux", version: "3.8.10-1-arch", arch: "amd64", family: "unix" | |
[INFO] Error stacktraces are turned on. | |
[DEBUG] Reading global settings from /opt/maven/conf/settings.xml | |
[DEBUG] Reading user settings from /home/antoras/.m2/settings.xml |
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
object Test extends App { | |
def x(in: Any): List[String] = in match { | |
case i: Int => List(i.toString) | |
case s: String => List(s) | |
case xs: List[_] => xs flatMap x | |
case _ => Nil | |
} |
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
import scala.util.parsing.combinator.JavaTokenParsers | |
trait FloatParser { | |
private object parsers extends JavaTokenParsers { | |
implicit class RichElem[A <% Parser[A]](p: A) { | |
def <::>(q: Parser[List[A]]) = p ~ q ^^ { case m ~ n => m :: n } | |
} |
NewerOlder