Wednesday, December 2, 2009

Memo: how to run the first django project

cd
mkdir django
cd django
django-admin.py startproject mysite
cd mysite
python manage.py runserver

These commands above surely works. After issuing these commands, simply access to the url "http://localhost:8000" and check the response.

To change the port number of the web server, try following commands:

python manage.py runserver 8080
python manage.py runserver 0.0.0.0:8000

Sunday, November 15, 2009

SICP - Exercise 1.3

;; [[Exercise]]                                                                                                              

;; Exercise 1.3:                                                                                                             
;; Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.    

;; [[Sample Answer]]                                                                                                         

(define (square x)
  (* x x))
(define (sum-of-squares-of-high-numbers a b c)
  (cond ((and (<= a b) (<= a c)) (+ (square b) (square c)))
        ((and (<= b a) (<= b c)) (+ (square a) (square c)))
        (else (+ (square a) (square b)))))

;; [[Sample Test]]

(sum-of-squares-of-high-numbers 1 2 3) ; 13                                                                                  
(sum-of-squares-of-high-numbers 1 3 2) ; 13                                                                                  
(sum-of-squares-of-high-numbers 2 1 3) ; 13                                                                                  
(sum-of-squares-of-high-numbers 2 3 1) ; 13                                                                                  
(sum-of-squares-of-high-numbers 3 1 2) ; 13                                                                                  
(sum-of-squares-of-high-numbers 3 2 1) ; 13                                                                                  
(sum-of-squares-of-high-numbers 1 1 1) ; 2                                                                                   
(sum-of-squares-of-high-numbers 1 2 2) ; 8                                                                                   
(sum-of-squares-of-high-numbers 1 1 2) ; 5

Friday, November 13, 2009

SICP - Exercise 1.2

;; [[Exercise]]

;; Exercise 1.2:
;; Translate the following expression into prefix form.
;;
;; (5 + 4 + (2 - (3 - (6 + 4/5)))) / (3 * (6 - 2) * (2 - 7))

;; [[Sample Answer]]

(/ (+ 5 (+ 4 (- 2 (- 3 (+ 6 (/ 4 5)))))) (* 3 (- 6 2) (- 2 7))) ; -37/150

Sunday, November 8, 2009

First post

This is a first post. I'm testing the features of Blogger.

Google

this is inside of the p tag.



this is inside of the em tag.


legacy table layout

this is inside of the h2 tag


int main() {
  printf("Hello, world!");

  return 0;
}