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
| for { | |
| _ <- pull("busybox:latest") | |
| cntr <- run("busybox", "sh", "-c", "while :; do sleep 1; done") | |
| res <- exec(cntr, "date") | |
| _ <- kill(cntr) | |
| _ <- remove(cntr) | |
| } yield 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
| object DockerClientApp extends App { | |
| import DockerClientOps._ | |
| val client:DockerClient = DefaultDockerClient.fromEnv().build() | |
| val interpreter = spotifyInterpreter(client) | |
| val program = for { | |
| _ <- pull("busybox:latest") | |
| cntrId <- run("busybox", "sh", "-c", "while :; do sleep 1; done") |
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 TernaryApp extends App { | |
| val ternary = Ternary[Boolean] | |
| .insert("East Richmond", true) | |
| .insert("East Eagle", true) | |
| .insert("Richmond West", true) | |
| .insert("Cheltenham", true) | |
| .insert("Richmond VIC", true) | |
| println(ternary.keys) | |
| // List(Cheltenham, East Eagle, East Richmond, Richmond VIC, Richmond West) |
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 TrieApp extends App { | |
| val trie = Trie[Int] | |
| .insert("to", 7) | |
| .insert("a", 15) | |
| .insert("tea", 3) | |
| .insert("ted", 4) | |
| .insert("ten", 12) | |
| .insert("i", 11) | |
| .insert("in", 5) | |
| .insert("inn", 9) |
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
| sealed trait Ternary[+A] { | |
| def insert[B >: A](key: String, value: B): Ternary[B] = Ternary.insert(this, key, value, 0) | |
| def search(key: String): Option[A] = Ternary.search(this, key, 0) | |
| def keys: List[String] = Ternary.keys(this) | |
| def keysWithPrefix(prefix: String): List[String] = Ternary.keys(this, prefix) | |
| } |
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
| case class Trie[V](value: Option[V], children: List[Option[Trie[V]]]) { | |
| def insert(key: String, value: V): Trie[V] = Trie.insert(this, key, value, 0) | |
| def delete(key: String): Trie[V] = Trie.delete(this, key, 0) | |
| def search(key: String): Option[V] = Trie.search(this, key, 0) | |
| } | |
| object Trie { | |
| def empty[V]: Trie[V] = new Trie[V](None, List.fill(26)(None)) |
NewerOlder