Skip to content

Instantly share code, notes, and snippets.

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
@phlamenco
phlamenco / main.go
Created July 21, 2018 08:38 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@phlamenco
phlamenco / class_register.h
Created March 26, 2018 07:20 — forked from rchatsiri/class_register.h
Register class creates factory class.
//
// Defines several helper macros for registering class by a string name and
// creating them later per the registered name.
// The motivation is to help implement the factory class. C++ doesn't support
// reflection so we defines several macros to do this.
//
// All macros defined here are NOT used by final user directly, they are used
// to create register macros for a specific base class. Here is an example:
/*
mapper.h (the interface definition):
@phlamenco
phlamenco / sse.go
Created July 31, 2017 08:31 — forked from schmohlio/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"