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
public class Person { | |
public String toJson() { | |
return "{" + | |
"firstName='" + firstName + '\'' + | |
", lastName='" + lastName + '\'' + | |
", nicknames=" + Arrays.toString(nicknames) + | |
'}'; | |
} |
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
interface ConfusionMatrixInterface { | |
Stream<String> getClassNames(); | |
int truePositive(String className); | |
int trueNegative(String className); | |
int falsePositive(String className); |
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
case class IslandState(destShore: ShoreSide, initialShore: ShoreSide) { | |
override def toString: String = s"dest:$destShore,init:$initialShore" | |
import IslandState._ | |
val isGameOver: Boolean = isFinalStateReached(destShore) | |
def getTheOtherShore(ss: ShoreSide): ShoreSide = if (destShore == ss) initialShore else destShore |
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>val emphasisFunc = (str:String) = s"$str!!!"" | |
emphasisFunc: (str: String)String | |
scala>emphasisFunc | |
def emphasisFunc(str: String): String | |
scala> emphasisFunc("abc") | |
res0: String = abc!!! | |
scala> List("hello","world").map(emphasisFunc) |
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> val etaexplained = emphasisFunc _ | |
etaexplained: String => String = $$Lambda$1239/712726821@5a5b394 | |
//what happens on multiple paramters list ? | |
//they get curried away. | |
//for example | |
scala> def strAddByNumAndMultiplty(str:String)(numToAdd:Int)(numToMultiply:Int) = str.toInt + numToAdd * numToMultiply | |
strAddByNumAndMultiplty: (str: String)(numToAdd: Int)(numToMultiply: Int)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
def offsetMonitor[F[_]: Functor, E, H[_]: Functor, T]( | |
monitor: H[{def set(offset:Long):Unit}] | |
): Flow[EnvT[E, F, ProducerResult[T]], EnvT[E, F, ProducerResult[T]], NotUsed] = | |
Flow[EnvT[E, F, ProducerResult[T]]].map { elem => | |
elem.map { e => | |
monitor.map { m => | |
m.set(e.env.offset) | |
} | |
} |
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
trait Trackable { | |
def setOffset(value: Long): Unit | |
} | |
trait Gauge { | |
def set(off: Long): Unit | |
} | |
val gauge: Gauge = ??? | |
val counter: AtomicLong = ??? |
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
trait Trackable[T] { | |
def trackValue(off: Long, item: T): Unit | |
} | |
trait Gauge { | |
def set(off: Long): Unit | |
} | |
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
trait Gauge { | |
def set(off: Long): Unit | |
} | |
val gauge: Gauge = ??? | |
val counter: AtomicLong = ??? | |
def offsetMonitor[A](monitor: Long=>Unit) = | |
monitor(12) |
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
def offsetMonitor[F[_]: Functor, E, H[_]: Functor, T]( | |
monitor: H[AtomicLong] | |
): Flow[EnvT[E, F, ProducerResult[T]], EnvT[E, F, ProducerResult[T]], NotUsed] = | |
Flow[EnvT[E, F, ProducerResult[T]]].map { elem => | |
elem.map { e => | |
monitor.map { m => | |
m.set(e.env.offset) | |
} | |
} |
OlderNewer