TODO: introduction
Note: the examples below use the following algebraic data type:
sealed trait Shape
case class Circle(radius: Double) extends Shape
case class Rectangle(height: Double, width: Double) extends Shape
module Payments where | |
data Customer = Customer { name :: String, age :: Int } deriving (Eq, Ord, Show) | |
-- I know partial record fields is an anti-pattern, but who's counting? | |
data Payment | |
= Cash { customer :: Customer, amount :: Double } | |
| Credit { customer :: Customer, amount :: Double, cardNumber :: Int } | |
| Check { customer :: Customer, amount :: Double, routingNumber :: Int, accountNumber :: Int } | |
deriving (Eq, Ord, Show) |
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
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
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"