I hereby claim:
- I am helenwilliamson on github.
- I am helenwilliamson (https://keybase.io/helenwilliamson) on keybase.
- I have a public key ASAusmMyI-_9FVBNEJffqY7s5AjSQIJIrRnafzt1fmZqkwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
data class Bob(val name: String, val live: Live) | |
data class Live(val value: Boolean) { | |
companion object { | |
fun apply(value: String?): Boolean = | |
value.let { | |
if (it.isNullOrBlank()) null else it | |
}?.toBoolean() ?: false | |
} | |
} |
/** | |
* Created by helen on 20/08/15. | |
*/ | |
object HarryPotterBasket { | |
val pricingStrategies = List(TwoBooksPricingStrategy) | |
def calculate(basket: List[HarryPotterSeries]): Double = { | |
pricingStrategies.map(_.price(basket)).head.price.get | |
} |
import java.io.File | |
import scala.io.Source | |
object MarkovChainApp extends App { | |
val tokenisedText = Source.fromFile(new File(args(0))).mkString.split(" ").map(_.trim) | |
val wordMap : Map[String, List[String]] = tokenisedText.sliding(2).foldLeft(Map[String, List[String]]().withDefaultValue(List.empty[String])) { | |
(dict, words) => { | |
dict.updated(words(0), words(1) :: dict(words(0)) ) |
import java.util.Date | |
import javafx.scene.Parent | |
import akka.actor._ | |
import akka.pattern.ask | |
import akka.util.Timeout | |
import scala.annotation.tailrec | |
import scala.concurrent.Future |
package main.scala | |
case class MutableThings(var stuff: List[String] = List()) { | |
println("Creating new MutableThings") | |
def addStuff(myStuff: String) = { | |
this.stuff = List(myStuff) | |
this | |
} | |
} |