Skip to content

Instantly share code, notes, and snippets.

Avatar

Creighton Kirkendall ckirkendall

  • Blue Manta Consulting
  • Cincinnati, Ohio
View GitHub Profile
View Applied-FP-with-Scala.md

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
@bkyrlach
bkyrlach / Jealousy.scala
Last active Dec 21, 2015
Some thoughts on implementing a logic DSL in Scala.
View Jealousy.scala
object Jealousy {
import Scalog._
def main(args: Array[String]): Unit = {
implicit val knowledge =
Functor("loves", "vincent", "mia") ::
Functor("loves", "marsellus", "mia") ::
Functor("loves", "pumpkin", "honey_bunny") ::
Functor("loves", "honey_bunny", "pumpkin") ::
Rule(Functor("jealous", "X", "Y"), Functor("loves", "X", "Z") and Functor("loves", "Y", "Z")) ::
Nil
@ckirkendall
ckirkendall / clojure-match.clj
Created Jun 15, 2012 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
View clojure-match.clj
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})