Skip to content

Instantly share code, notes, and snippets.

/**
* Make a lazy value type as a thunk
*/
/**
* Lazy value wihtout memoization
*/
case class LazyVal[A](thunk : () => A) {
def value : A = this.thunk()
@mioalter
mioalter / PimpMyMonoid.scala
Last active April 6, 2016 20:13
Pimp My Monoid
// You have two numbers represented as linked lists, where each node contains a single digit.
// The digits are stored in reverse order, such that the 1’s digit is at the head of the list.
// Write a function that adds the two numbers and returns the sum as a linked list.
//
// EXAMPLE
// Input: (3 -> 1 -> 5) + (5 -> 9 -> 2)
// Output: 8 -> 0 -> 8
//
case class Lint(digits : List[Int]) {require (digits.map(_ / 10).sum == 0)}
// Lintegers, integers as lists of digits
CREATE TABLE IF NOT EXISTS normalized (
gram string,
year int,
occurrences bigint
);
INSERT OVERWRITE TABLE normalized
SELECT
lower(gram),
year,