This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang planet neil/sicp | |
(define (square guess) | |
(* guess guess)) | |
(define (average x y) | |
(/ (+ x y) 2)) | |
(define (sqrt x) | |
(define (good-enough? guess) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style type="text/css"> | |
.center { | |
text-align: center; | |
} | |
@-webkit-keyframes blink { | |
from { opacity: 1.0; } | |
to { opacity: 0.0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INFINITY = 1.0 / 0 | |
p 1.upto(INFINITY). | |
lazy. | |
map { |n| n + 1 }. | |
select { |n| n.even? }. | |
first | |
#=> 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kanren | |
extend self | |
# Syntax | |
# A goal that always succeeds | |
def succeed | |
->(a) { a } | |
end | |
# A goal that always fails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+-------------------------------------------------------+ | |
|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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |