Skip to content

Instantly share code, notes, and snippets.

View lutzh's full-sized avatar

Lutz Hühnken lutzh

View GitHub Profile
@lutzh
lutzh / currency.scala
Created April 7, 2019 11:36
Currency example for Mathias
// Start Scala
// :paste the following:
object Currencies {
sealed trait Rate {
def to(currency: Rate, amount: Double): Money
}

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x

Keybase proof

I hereby claim:

  • I am lutzh on github.
  • I am lutzh (https://keybase.io/lutzh) on keybase.
  • I have a public key whose fingerprint is 0792 9D85 E164 3F6E 9D9A FA9A 7BD5 61B6 49B0 0F70

To claim this, I am signing this object:

trait A {
def action() = println("a")
}
trait B extends A {
override def action() = println("b")
}
trait C {
def action() = println("c")
/*
* Copyright © 2012 Typesafe, Inc. All rights reserved.
*/
package com.typesafe.training.scalatrain
object TestData {
val munich = Station("Munich")
def connections(from: Station, to: Station, departureTime: Time): Set[Seq[Hop]] = {
require(from != to)
def connections(from: Station, departureTime: Time, visitedStations: Set[Station]): Set[Seq[Hop]] =
{
val hopsFrom: Set[Hop] = hops.getOrElse(from, Set[Hop]())
hopsFrom.filter(hop => hop.departureTime >= departureTime)
.filterNot(hop => visitedStations.contains(hop.to))
.flatMap(hop =>
@lutzh
lutzh / libcaca 0.99b18 did not build
Created April 10, 2014 08:01
libcaca 0.99b18 did not build
➜ ~ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: b984d3e996321207b35af391d5f1f6ef2aaa1774
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit sandybridge
OS X: 10.9.2-x86_64