Skip to content

Instantly share code, notes, and snippets.

@Rubentxu
Rubentxu / maybe.go
Created September 24, 2015 23:34
Implementing the Maybe monad in Golang
package main
import (
"fmt"
"errors"
)
type Maybe interface {
Return(value interface{}) Maybe
Bind(func(interface{}) Maybe) Maybe
@signed0
signed0 / gist:2252148
Created March 30, 2012 15:03
Douglas Peucker
from math import sqrt
from itertools import islice, chain
def subtract_coords(a, b):
'''Returns a - b'''
return (a[0] - b[0], a[1] - b[1])
def dot_product(a, b):
return a[0] * b[0] + a[1] * b[1]
@signed0
signed0 / gist:1731010
Created February 3, 2012 16:38
Lazy loding method decorator
''''
From http://code.activestate.com/recipes/363602-lazy-property-evaluation/
Usage:
class MyClass():
@lazyloaded
def config(self):
return {'yay': 'nay'}