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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; A simple orrery in clojure. Models a 2-dimensional, | |
;; orthogonal solar system, with the planets most definitely | |
;; not to scale. | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(ns orrery | |
(:import [java.awt Color Dimension] | |
[java.awt.event ActionListener] | |
[javax.swing JFrame JPanel Timer])) |
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 scheme | |
;some quick code for approximating definite integrals | |
;Trapezoid Rule approximation for the integral of f over range (a,b) in n divisions | |
(define (area-trap f a b n) | |
(let ([dx (/ (- b a) n)]) | |
(define (iter x list) | |
(cond ((= x b) | |
(iter (- x dx) (cons (f x) list))) | |
((= x a) |
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
//The game of Snake in Scala | |
package snake | |
import javax.swing.{JFrame,JPanel,Timer} | |
import java.awt.Graphics | |
import java.awt.event.{ActionEvent,ActionListener,KeyListener,KeyEvent} | |
import scala.actors.Actor | |
import scala.actors.Actor._ | |
case class Listen(actor: Actor) |
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
# Solves a randomized 8-puzzle using A* algorithm with plug-in heuristics | |
import random | |
import math | |
_goal_state = [[1,2,3], | |
[4,5,6], | |
[7,8,0]] | |
def index(item, seq): |