Skip to content

Instantly share code, notes, and snippets.

View ckirkendall's full-sized avatar

Creighton Kirkendall ckirkendall

  • Blue Manta Consulting
  • Cincinnati, Ohio
View GitHub Profile

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 / Jealousy.scala
Last active December 21, 2015 04:58
Some thoughts on implementing a logic DSL in 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")) ::
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(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})