Skip to content

Instantly share code, notes, and snippets.

View AlvaroCaste's full-sized avatar
👋

Álvaro Castellanos López AlvaroCaste

👋
  • LeadIQ
  • Spain
View GitHub Profile
@non
non / mark.scala
Created January 3, 2017 15:00
Scala solver for Mark Dominus' arithmetic puzzle (http://blog.plover.com/math/17-puzzle.html).
package mark
import spire.math.{ Rational => Q }
object Solver2 {
case class Op(name: String, run: (Q, Q) => Option[Q])
val ops: List[Op] = List(
Op("+", (x, y) => Some(x + y)),

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 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