Skip to content

Instantly share code, notes, and snippets.

Lee Spector lspector

Block or report user

Report or block lspector

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lspector
lspector / maria.clj
Last active Sep 24, 2018
A gist to experiment with maria.cloud
View maria.clj
(defn maria
[]
(+ 1 3))
@lspector
lspector / palindrome.clj
Last active Feb 14, 2018
A simple genetic algorithm for evolving a palindrome, in Clojure in a Gorilla REPL worksheet; view at http://viewer.gorilla-repl.org/view.html?source=gist&id=e0afea6bba84c1317a765b4da55ae0c6
View palindrome.clj
;; gorilla-repl.fileformat = 1
;; **
;;; # Palindrome
;;;
;;; Lee Spector, lspector@hampshire.edu, 20180213
;;;
;;; Here's another simple genetic algorithm demonstration, this one for evolving a palindrome -- a word that's the same backwards as forwards.
;;;
;;; We could represent words as strings of characters, but some things are a little simpler to do with vectors, so here we'll represent words as vectors of single-letter symbols.
@lspector
lspector / primes.clj
Last active Feb 8, 2018
Some Clojure code from class, for testing primality, in a Gorilla REPL worksheet. View: http://viewer.gorilla-repl.org/view.html?source=gist&id=766a20c30fb54f009e4e8a38173a4910
View primes.clj
;; gorilla-repl.fileformat = 1
;; **
;;; # Primes
;; **
;; @@
(ns primes)
;; @@
;; =>
View self-eval-music.clj
;; gorilla-repl.fileformat = 1
;; **
;;; # Self-eval music
;;;
;;; Lee Spector, 2017
;;;
;;; This is code for turning self-evaluations into music, for CS263: Artificial Intelligence at Hampshire College. The output can be played via [Klangmeister](http://ctford.github.io/klangmeister/).
;;;
;; **
View self-eval-scramble.clj
;; gorilla-repl.fileformat = 1
;; **
;;; # Self-eval scramble
;;;
;;; Lee Spector, 2017
;;;
;;; This is code for Markov chain scrambling of self-evaluations for CS263: Artificial Intelligence at Hampshire College.
;;;
;;; In this text scrambler, we start with a random word and then follow it by some word that follows that word in the original text, with the probabilities for the following words derived from the numbers of times that they follow the first word in the original text. Then we repeat the process to choose a word to follow the second word, and so on. While it's possible to do this by computing the probabilities of all word pairs in the input, we can do it more simply, and achieve the same results, with random rotations.
View ga.clj
;; gorilla-repl.fileformat = 1
;; **
;;; # A Simple Genetic Algorithm to Solve a Silly, Made-Up Problem
;;;
;;; Here we'll demonstrate the core concepts of genetic algorithms, in Clojure, by writing code to evolve a sequence of 5 integers between 1 and 100 (inclusive) that, when divided in sequence, produce 5.
;;;
;;; That is, we want numbers a, b, c, d, e such that `a / b / c / d / e = 5`
;;;
;;; It's a silly, made-up problem, but it will nonetheless allow us to see how genetic algorithms work, and how to implement them in Clojure.
View search-worksheet.clj
;; gorilla-repl.fileformat = 1
;; **
;;; # Search
;;;
;;; Lecture notes on AI search algorithms, with Clojure code.
;;;
;;; Lee Spector, lspector@hampshire.edu, 20141015-20170930
;;;
;;; Some of the code here was adapted from the [search.lisp](https://norvig.com/paip/search.lisp) Common Lisp code in Peter Norvig's Paradigms of AI Programming (1991), but with substantial modifications.
@lspector
lspector / search.clj
Last active Aug 29, 2015
AI search code
View search.clj
(ns search.core)
;; Lecture notes on AI search algorithms.
;; Lee Spector, lspector@hampshire.edu, 20141015
#_(defn is-5 [n]
(= n 5))
#_(filter is-5 [1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1])
@lspector
lspector / vp2d.clj
Created Apr 10, 2014
Initial sketches toward a 2d swarm-like alife system in Clojure/Quil
View vp2d.clj
;; Initial sketches toward a 2d swarm-like alife system in Clojure/Quil
;; Lee Spector, lspector@hampshire.edu, 20140409
(ns vp2d.core
(:use quil.core)
(:gen-class))
(def all-pods (atom []))
(def iteration (atom 0))
@lspector
lspector / notes.clj
Created Feb 4, 2014
Minimal example of how to play a melody using Clojure/Overtone/Leipzig
View notes.clj
;; Minimal example of how to play a melody using Clojure/Overtone/Leipzig, based on code
;; at https://github.com/ctford/leipzig
;; by Lee Spector, lspector@hampshire.edu, 20140204
;; Add the following to your dependencies in project.cl, and do "lein deps" if your environment requires it:
;; [leipzig "0.7.0"]
(ns notes.core
(:use [leipzig melody scale live]
You can’t perform that action at this time.