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.util.parsing.combinator.JavaTokenParsers | |
| import scala.util.matching.Regex | |
| import scala.util.parsing.input.OffsetPosition | |
| import Tokens._ | |
| object T1 extends App with P { | |
| val source = "abc = def\nabcd=def\nabc\t= \t\t defg" | |
| val parsed = parseAll(lines, source) match { | |
| case Success(res, _) => res |
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
| public class MM { | |
| public void meth(final scala.Function1<Object, scala.runtime.BoxedUnit> f) { | |
| } | |
| } | |
| /* | |
| % javap -c -s -l -verbose -private MM | |
| Compiled from "MM.java" |
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 X { | |
| class EitherProvidesProjection[A, B](e: Either[A, B]) { | |
| def project[A1](f: A => A1) = e match { | |
| case Left(l) => Left(f(l)).right | |
| case Right(r) => Right(r).right | |
| } | |
| } | |
| implicit def EitherProvidesProjection[A, B](e: Either[A, B]) = new EitherProvidesProjection(e) | |
| for { |
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
| \documentclass{article} | |
| \usepackage[utf8]{inputenc} | |
| \usepackage[T1]{fontenc} | |
| \usepackage{amsfonts} | |
| \usepackage{amsmath} | |
| \usepackage{mathtools} | |
| \usepackage[margin=2cm]{geometry} % margins | |
| \usepackage{fancyhdr} % site layout | |
| \usepackage{datetime} | |
| \usepackage{soul} |
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.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 |
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.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 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 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 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 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 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 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 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
| /* | |
| * 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> |