-
Coursera's Learning how to Learn course is starting again. https://www.coursera.org/learn/learning-how-to-learn If you prefer the written version, take a look at Barbara Oakley book https://www.amazon.com/Mind-Numbers-Science-Flunked-Algebra-ebook/dp/B00G3L19ZU
-
Take a look at how we think with Kahneman's Thinking Fast and Slow http://www.amazon.com/Thinking-Fast-Slow-Daniel-Kahneman/dp/0374533555
-
Uncle Bob inspires you to keep learning as a professional. http://www.amazon.com/Clean-Coder-Conduct-Professional-Programmers/dp/0137081073
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 akka.actor._ | |
object SimpleSieve extends App { | |
val MaxNumber = 500000 | |
case object NoMoreCandidates | |
class Filter extends Actor { |
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 akka.actor._ | |
object BackPressureSieve extends App { | |
val DefaultChunkSize = 1024 | |
val MinChunkSize = DefaultChunkSize * 3 / 4 | |
val MaxNumber = 500000 | |
case object GetCandidates | |
case class Candidates(values: Vector[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
class Sieve(maxNumber: Int) { | |
private val candidates = Array.fill(maxNumber + 1)(true) | |
def run(): Unit = { | |
for (index <- 2 to maxNumber) { | |
if (candidates(index)) { | |
crossOutMultiples(index) | |
} | |
} | |
} |
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
package distro | |
import scala.annotation.tailrec | |
import scala.util.Random | |
trait Distro[A] { | |
def eventSet: Set[A] | |
def probOf(event: A): BigDecimal | |
def map[B](f: A => B): Distro[B] | |
def flatMap[B](f: A => Distro[B]): Distro[B] |
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
package lines | |
import java.io.File | |
import scala.annotation.tailrec | |
object LineCount { | |
def of(file: File): Int = { | |
val source = scala.io.Source.fromFile(file) | |
try of(source.toStream) |
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> def yearlyImprove(dailyImprove: Double): Double = | |
| Seq.fill(365)(1 + dailyImprove).product - 1 | |
yearlyImprove: (dailyImprove: Double)Double | |
scala> yearlyImprove(0.001) | |
res0: Double = 0.44025131342952095 |
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
package sandbox; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.EnumSet; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Set; | |
import java.util.function.BiConsumer; | |
import java.util.function.BinaryOperator; |
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.util.parsing.combinator.RegexParsers | |
sealed trait Command | |
case object FlushCommand extends Command | |
case class LookupKey(key: String) extends Command | |
case class SetKey(key: String, blob: String) extends Command | |
object Grammar extends RegexParsers { | |
val id: Parser[String] = """[a-zA-Z][a-zA-Z0-9]*""".r |
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
{-# LANGUAGE FlexibleInstances, OverlappingInstances #-} | |
import Data.List | |
toJson1 :: [String] -> String | |
toJson1 elems = toArray $ map quote elems | |
where quote elem = '"' : elem ++ "\"" | |
toArray elems = '[' : concat (intersperse ", " elems) ++ "]" | |
sample1 = toJson1 ["a", "b", "c"] |