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 Example3 extends App { | |
import games.board.xgame._ | |
val game = new XGame() with reporting.ConsoleReporter | |
implicit val board = game.board(5, 5) | |
import Commands._ | |
import BluePlayer.{ Frog => BlueFrog, Stork => BlueStork } | |
import RedPlayer.{ Frog => RedFrog, Stork => RedStork } |
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.collection.mutable.{ ListBuffer, HashMap } | |
object LZW { | |
private val initialDictionaryCompress: Seq[(String, Int)] = (0 until 256) map (i => ("" + i.toChar, i)) | |
private val initialDictionaryDecompress: Seq[(Int, String)] = (0 until 256) map (i => (i, "" + i.toChar)) | |
def compress(uncompressed: String): Seq[Int] = { | |
val dictionary = HashMap(initialDictionaryCompress: _*) | |
val result = new ListBuffer[Int]() |
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 FutureOfEitherT { | |
type Result[T] = Either[Throwable, T] | |
implicit class FutureOps[T](val f: Future[T]) extends AnyVal { | |
implicit def orFail: FutureOfEither[T] = | |
FutureOfEither(f map Right.apply recover { case NonFatal(e) => Left(e) }) | |
} |
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.nio.charset.Charset | |
import org.scalatest.{Matchers, WordSpec} | |
import scala.util.Random | |
class CRC5Spec extends WordSpec with Matchers { | |
/** | |
* Implements a "normal" MSB-first byte-width CRC5 function using a lookup table. |
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.reflect.ClassTag | |
/** Mutable, indexed buffer abstraction. | |
* | |
* @groupprio Abstract 0 | |
* @groupprio Properties 1 | |
* @groupprio Update 2 | |
* @groupprio Append 3 | |
* @groupprio Insert 4 | |
* @groupprio Shift 5 |
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
/** | |
* ISO 3166-1 alpha-3 codes are three-letter country codes defined in ISO 3166-1, | |
* part of the ISO 3166 standard published by the International Organization for Standardization (ISO), | |
* to represent countries, dependent territories, and special areas of geographical interest. | |
*/ | |
object ISO31661Alpha3 { | |
def apply(code: String): Option[String] = code2Country.get(code) | |
final private val code2Country = Map( |
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
//> using scala "2.13.8" | |
//> using lib "com.typesafe.play::play-ahc-ws-standalone:2.1.3" | |
//> using lib "com.typesafe.play::play-ws-standalone-json:2.1.3" | |
import java.time.LocalDate | |
import java.time.format.DateTimeFormatter | |
import akka.actor.ActorSystem | |
import play.api.libs.ws._ | |
import play.api.libs.ws.ahc._ |
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
sealed trait Direction | |
sealed trait East extends Direction | |
case object East extends East | |
sealed trait West extends Direction | |
case object West extends West | |
sealed trait North extends Direction | |
case object North extends North | |
sealed trait South extends Direction | |
case object South extends South |
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.reflect.ClassTag | |
trait AnyWordSpecCompat extends munit.FunSuite { | |
implicit class NameExt[T](name: String) { | |
def in(body: => T): Unit = test(name)(body) | |
def should(body: => T): Unit = { | |
val pos0 = munitTestsBuffer.length |
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.{Timer, TimerTask} | |
import java.util.Date | |
import scala.concurrent._ | |
import scala.concurrent.duration.FiniteDuration | |
import scala.util.Try | |
import scala.util.Success | |
import scala.util.Failure | |
object Schedule { |