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
;;function lis-length returns the length of a list | |
;;list -> number | |
(define (lis-length lis) | |
(cond [(empty? lis) 0] | |
[else (add1 (lis-length (rest lis)))])) | |
(check-expect (lis-length (list 1 2 3 4 5)) 5) | |
(check-expect (lis-length empty) 0) | |
(check-expect (lis-length (list 1)) 1) |
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 racket/base | |
(require rsound) | |
(require rsound/piano-tones) | |
(require racket/list) | |
(require "markov.rkt") | |
;; a note is (make-note note-num frames frames) | |
(define-struct note (pitch time duration)) | |
(define (note->note* old) |
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
def car(x): | |
return x[0] | |
def cdr(x): | |
return x[1:] | |
#define some things that we can do in our arithmatic language | |
def plus(x): | |
if x == []: | |
return 0 | |
else: |
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 racket | |
(require rackunit) | |
(require racket/list) | |
(define board (list (list 0 0 0 0) | |
(list 0 2 0 0) | |
(list 0 0 0 0) | |
(list 0 0 0 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
import math | |
def frequentist(facts): | |
m = max(facts) | |
k = len(facts) | |
return m + (float(m) / k) - 1 | |
def bayesian(facts): | |
m = float(max(facts)) | |
k = float(len(facts)) |
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
rgfdlj rjgrldj,xlarjcrgsrgllj;rsrr |
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
import numpy, math | |
from scipy import linalg | |
# Let |terms| be a list of lambdas... one for each term | |
# the result is a linear combination of them applied to x | |
terms = [ | |
lambda x: 1, | |
lambda x: math.log( x ), | |
lambda x: math.log( x ) ** 3 | |
] |
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
if [ -z "$WP" ]; then | |
# $WP is empty... you are not in a chroot workspace | |
export PS1="\[\033[0;31m\]"$PS1"\[\033[0m\]" | |
else | |
# $WP contains the name of the project you're currently in | |
export PS1="\[\033[0;37m\]"$WP": "$PS1"\[\033[0m\]" | |
fi |
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
import sys, os, subprocess, errno, time | |
class BadArgsException( Exception ): | |
pass | |
class FileLock: | |
def __init__( self, lockfile, delay=1.0 ): | |
""" Acquire the lock, if possible. If the lock is in use, it check again | |
every `wait` seconds. It does this until it either gets the lock or | |
exceeds `timeout` number of seconds, in which case it throws |
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
import sys, os, subprocess, errno, time | |
class FileLock: | |
def __init__( self, lockfile, delay=1.0 ): | |
self.is_locked = False | |
self.lockfile = lockfile | |
while True: | |
try: | |
self.fd = os.open( self.lockfile, os.O_CREAT | os.O_EXCL | os.O_RDWR ) | |
break; |
OlderNewer