Skip to content

Instantly share code, notes, and snippets.

View nanne007's full-sized avatar
🏠
Working from home

cw nanne007

🏠
Working from home
View GitHub Profile
@nanne007
nanne007 / thought-in-y-combinator.rkt
Created March 21, 2014 08:59
evolution of Y combinator
#lang racket
;;; a definition of Y(notice: it's not Y Combinator),
;;; which can run in a strict language
; (Y f) = (f (Y f)) = (f (lambda (x) ((Y f) x)))
(define Y
(lambda (f)
(f (lambda (x) ((Y f) x)))))
(define almost-factorial
@nanne007
nanne007 / repeat_until.scala
Last active December 28, 2015 07:09
repeat { command } until(condition) syntax in scala
def repeat(c: => Unit) = new {
def until(p: => Boolean): Unit = {
c
if(p) ()
else until(p)
}
}
class Class
def to_proc
proc { |x, y| new x, y }
end
end
p [[1, 'a'], [2, 'b'], [3, 'c']].map &Array