Skip to content

Instantly share code, notes, and snippets.

View enigmaticape's full-sized avatar

Enigmatic Ape enigmaticape

View GitHub Profile
@enigmaticape
enigmaticape / pascal-element.scm
Created November 4, 2012 16:31
Recursivley compute the elements of Pascal's triangle in Scheme. Answer to SICP exercise 1.12
;; Recursive function to compute the elements
;; of Pascal's triangle. Note the complete lack
;; of any sanity checks on the input. GIGO.
(define (pelem row col)
(cond((= col 0) 1)
((= col row) 1)
(else(+(pelem(- row 1)(- col 1))
(pelem(- row 1) col) ) )))
@enigmaticape
enigmaticape / sicp_1_13_pyfib.py
Created November 4, 2012 15:07
Various python code to do Fibonacci related computations
#!/usr/bin/python
# This is the python script I used to generate
# the table that illustrates my rambling answer
# to SICP exercise 1.13
import math
# Golden ratio and conjugate
phi = (1 + math.sqrt( 5 ) ) / 2
@enigmaticape
enigmaticape / sicp_ex_1.13.scm
Created November 4, 2012 13:22
Some code to go with an exploration of SICP exercise 1.13, a proof of closed form of Fibonacci function.
;; expt is three characters too long on the REPL
;; I use on my iPhone
(define (^ x n) (expt x n))
;; Golden Ratio, phi and the conjugate, psi
(define psi (/ (- 1 (sqrt 5)) 2))
(define phi (/ (+ 1 (sqrt 5)) 2))
;; Linear recursive Fib
(define (fib n)
<?php
if( ($dir = session_save_path() ) == null ) {
$dir = sys_get_temp_dir();
}
var_dump( $dir );
if( $dir ) {