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 HelloWorld extends App { | |
val msg = new Hello with World | |
msg.show | |
} | |
trait Message { | |
def get: String | |
} | |
trait World extends Message { |
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 akka.actor.Actor | |
import akka.actor.Actor.actorOf | |
object HelloWorld extends App { | |
val a = actorOf[Hello] | |
a.start() | |
val resp = (a !! World) getOrElse sys.error("no response") | |
a.stop() | |
println(resp) |
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
package listimpl | |
import org.specs2.mutable.SpecificationWithJUnit | |
import org.specs2.specification.Scope | |
class LinkedListTest extends SpecificationWithJUnit { | |
"LinkedList" should { | |
"have elements" in new Test { | |
xs.size === 3 |
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
/* | |
* TMP brainfuck compiler | |
* | |
* compile with: g++ -std=c++0x -Wall -Wextra -ftemplate-depth=2000 <file>.cpp | |
* compile version: g++ >= 4.6.1 | |
*/ | |
#include <cstddef> | |
#include <cstdio> | |
#include <utility> | |
#include <type_traits> |
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.util.Comparator; | |
import java.util.Iterator; | |
import java.util.functions.*; | |
interface Function0<R> { | |
R apply(); | |
} | |
interface Function1<P1, R> { | |
R apply(P1 p1); |
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.util.Comparator; | |
import static java.util.Comparators.*; | |
import java.util.functions.*; | |
/** | |
* The list dependency can be found at: https://gist.github.com/1989662 | |
* <p> | |
* ATTENTION: This code compiles only with JDK1.8 and project lambda which can | |
* be found at http://jdk8.java.net/lambda/ and is not production ready. | |
* |
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.util.NoSuchElementException; | |
import java.util.functions.*; | |
/** | |
* Represents optional values. Instances of Option are either an instance of | |
* Some or the singleton object NONE. | |
* <p> | |
* The list dependency can be found at: https://gist.github.com/1989662 | |
* <p> | |
* ATTENTION: This code compiles only with JDK1.8 and project lambda which can |
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 Shell extends App with InputHandler { | |
var game = Game.empty | |
run() | |
def run() { | |
val reader = Iterator.continually(readLine("othello> ").trim) | |
reader takeWhile ("quit" !=) filter (_.nonEmpty) foreach handleInput |
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 | |
import scala.util.Try | |
/* | |
* Compiles only with 2.10 | |
*/ | |
object Othello extends App with InputHandler { | |
private[this] var game = Game.empty |
OlderNewer