Skip to content

Instantly share code, notes, and snippets.

View bryanwoods's full-sized avatar
💭
Replacing Security Deposits

Bryan Woods bryanwoods

💭
Replacing Security Deposits
View GitHub Profile
class Mammal
constructor: (@name) ->
class Kitty extends Mammal
sayHello: -> "Meow! My name is: #{@name}"
class Purrpy extends Mammal
sayHello: -> "Woof! My name is: #{@name}"
leopold = new Kitty("Leopold")
#lang planet neil/sicp
(define (count-change amount start-time)
(cc amount 5)
(report-result (- (runtime) start-time)))
(define (cc amount kinds-of-coins)
(cond ((= amount 0) 1)
((or (< amount 0) (= kinds-of-coins 0)) 0)
(else (+ (cc amount
class Mammal
constructor: (@name, @age) ->
getName: -> @name
class Kitty extends Mammal
getName: -> "Meow! My name is: #{@name}"
leopold = new Kitty("Leopold", 6)
console.log(leopold.getName())
#lang planet neil/sicp
(define (square guess)
(* guess guess))
(define (average x y)
(/ (+ x y) 2))
(define (sqrt x)
(define (good-enough? guess)
<html>
<head>
<style type="text/css">
.center {
text-align: center;
}
@-webkit-keyframes blink {
from { opacity: 1.0; }
to { opacity: 0.0; }
@bryanwoods
bryanwoods / MyMap.hs
Created March 6, 2013 14:31
Implementing Map
myMap :: (a -> b) -> [a] -> [b]
myMap f (x:xs) = f x : myMap f xs
myMap _ _ = []
main = do
putStrLn . show $ myMap (+1) [1..10]
-- bryan@colvin:~$ ./mymap
-- [2,3,4,5,6,7,8,9,10,11]
@bryanwoods
bryanwoods / kindalazy.rb
Created February 27, 2013 22:34
Enumerator::SometimesLazy
INFINITY = 1.0 / 0
p 1.upto(INFINITY).
lazy.
map { |n| n + 1 }.
select { |n| n.even? }.
first
#=> 2
module Kanren
extend self
# Syntax
# A goal that always succeeds
def succeed
->(a) { a }
end
# A goal that always fails
@bryanwoods
bryanwoods / ascii.log
Last active December 12, 2015 08:08
An ascii lumberjack hacking ascii logs
+-------------------------------------------------------+
|ooooooooooooooooo+~ ~+ooooooooooooooooooooooooooooooo|
|oooooooooooooooo: :ooooooooooooooooooooooooooooo|
|oooooooooooooo+. +ooooooooooooooooooooooooooo|
|oooooooooooooo: .::+ ~ooooooooooooooooooooooooooo|
|ooooooooooooo+. :++oooo+o+~ooooooooooooooooooooooooooo|
|ooooo+o++o++oo~~ooo+oo+++o+:ooooooooooooooooooooooooooo|
|oooo+ooooo~+oo::+ooooo:ooo++ooooooooooooooooooooooooooo|
|oo++oooo+ ~oooo+ +o+. ~.~ :oooooooooooooooooooooooooooo|
|oo~+oooo :.~:++ .ooooooo+o+oooooooooooooooooo|
@bryanwoods
bryanwoods / beans.clj
Last active December 12, 2015 07:58
Having fun with core.logic
(ns my-kanren.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn -main [& args]
(run* [l]
(fresh [d x y w s]
(conso w (list 'a 'n 's) s)
(resto l s)
(firsto l x)