Skip to content

Instantly share code, notes, and snippets.

View ananthakumaran's full-sized avatar

Anantha Kumaran ananthakumaran

View GitHub Profile
@ananthakumaran
ananthakumaran / sqrt.ss
Created April 21, 2010 06:38
SICP ex 1.7
;; finds the sqrt of a number using newton's method
(define sqrt
(lambda (x)
(sqrt-iter 1.0 x)))
(define sqrt-iter
(lambda (guess x)
(if (good-enough? guess x)
guess
@ananthakumaran
ananthakumaran / cube.ss
Created April 21, 2010 06:41
SICP ex 1.8
;; finds the cube root of a number using newton method
(define cube
(lambda (x)
(cube-iter 1.0 x)))
(define cube-iter
(lambda (guess x)
(if (good-enough? guess x)
guess
;;A function f is defined by the rule that f(n) = n if n<3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n -3)
;;if n> 3. Write a procedure that computes f by means of a recursive process. Write a procedure that
;;computes f by means of an iterative process.
(define (f n)
(cond
((< n 3) 0)
(else
(iter-fun n 0 1 2))))
;;How many different ways can we make change of $ 1.00, given half-dollars, quarters,
;;dimes, nickels, and pennies? More generally, can we write a procedure to compute
;;the number of ways to change any given amount of money?
(define (count-change amount)
(cc amount 5))
(define (cc amount kinds-of-coins)
(cond
((= 0 amount) 1)
@ananthakumaran
ananthakumaran / blog_grabber.rb
Created April 23, 2010 17:49
grabs the posts of steve yegge
# grabs all the post from steve-yegge blog
require 'net/http'
require '/home/ananth/.gem/ruby/1.8/gems/xml-simple-1.0.12/lib/xmlsimple'
blog = 'www.blogger.com'
out_dir = '/home/ananth/steve-yegge/'
proxy_host = 'proxy.karunya.edu'
proxy_port = 3128
;; style your emacs with css
(setq source "
frame {
foreground-color : wheat;
background-color: darklategrey;
background-mode : dark
}
require 'rubygems'
require 'hpricot'
require 'net/http'
blog = 'www.paulgraham.com'
out_dir = '/home/ananth/paul/'
url = URI.parse('http://paulgraham.com/articles.html')
def time_taken
start_time = Time.now
yield
Time.now - start_time
end
def fib(n)
if n < 2
n
else
Gems included by the bundle:
* activesupport (2.3.8)
* bcrypt-ruby (2.1.2)
* beanstalk-client (1.1.0)
* bson (1.0.7)
* bson_ext (1.0.7)
* builder (2.1.2)
* bundler (1.0.0)
* compass (0.8.17)
* crack (0.1.8)
;;; haml-mode.el --- Major mode for editing Haml files
;; Copyright (c) 2007, 2008 Nathan Weizenbaum
;; Author: Nathan Weizenbaum
;; URL: http://github.com/nex3/haml/tree/master
;; Version: 3.0.13
;; Created: 2007-03-08
;; By: Nathan Weizenbaum
;; Keywords: markup, language, html