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 life (:use clojure.test clojure.set)) | |
(def under-populated 1) | |
(def over-populated 4) | |
(def fertile 3) | |
(defn north [[x y]] [x (inc y)]) | |
(defn south [[x y]] [x (dec y)]) | |
(defn east [[x y]] [(inc x) y]) | |
(defn west [[x y]] [(dec x) y]) |
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
#!/usr/local/bin/ruby | |
require 'find' | |
p "This script will copy the contents of your LEGO MINDSTORMS NXT disc to your desktop, make necessary adjustments to the installer for Mac OS X 10.6 and later, and then initiate the MINDSTORMS installer. Please insert the MINDSTORMS NXT disc before you continue. Would you like to continue? (Y/N)" | |
$name = gets.chomp | |
if $name[0,1].casecmp("Y") == 0 | |
$NXT_CD_Mounted = false | |
Dir.entries("/Volumes").each do |path| |
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 Lisp | |
def initialize | |
@env = { | |
:label => lambda { |(name,val), _| @env[name] = val }, | |
:quote => lambda { |sexpr, _| sexpr[0] }, | |
:car => lambda { |(list), _| list[0] }, | |
:cdr => lambda { |(list), _| list.drop 1 }, | |
:cons => lambda { |(e,cell), _| [e] + cell }, | |
:eq => lambda { |(l,r), _| l == r }, | |
:if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) }, |