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
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
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
% 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 | |
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 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 } | |
} |
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
package macros | |
import language.experimental.macros | |
import scala.reflect.macros.Macro | |
object Macros { | |
def swap(a: _, b: _) = macro Impl.swap | |
} | |
trait Impl extends Macro { |
NewerOlder