Tuesday, October 25, 2005

My new comp

I bought my 3rd comp. This time, its a laptop. An Acer TravelMate 2410 (this was the cheapest of all). I used to think laptops were waste, it still is in some sense .. with that money, i could have gone for a much better desktop system. But laptops have their own advantages .. mainly for me, it means i could read and rarely program from my bed, while watching tv etc :)

Here is the config ..
Intel Celeron M 360 (some 1.4 or 1.6GHz, forgot)
256MB Ram, 40GB Harddisk, 15" screen and a bunch of other crap ..

I always wanted a small laptop (a 12" .. it looks so cool), but unfortunately i got a 15" (as i said, i went for the cheapest one) .. its slightly bigger, and well, doesnt look good on lap. Also screen is pathetic (i didnt notice the laptop screens much before this) .. the laptop screen tends to have a bluish tint with a little bit of gamma.. (i checked with the thinkpad here in office)

It came with some Lupus linux (hell it didnt even have GUI) .. i tried installing Fedora Core, but its identifying as VESA .. i need to find the proper drivers ..

Graphics is pretty ok .. it gives around 80fps in 640x480 quake3 and is playable (40 fps i guess) in 1024x728 with high settings .. but again, the screen makes it pathetic to play with (it has upto 128MB shared mem)

All in all its an okay system, comparing the price.. it cost me 32k with carry bag (damn im bankrupt again) ..


Friday, October 14, 2005

Lisp

I am learning Lisp. Why and how, i will tell later. But one thing that struck me while learning is how common Python and Lisp are. I will now present some Python/Lisp snippets. If you can read Python, you sure can read Lisp.

Here is a code for factorial in Python

def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)

Now code in Lisp

(defun factorial (n)
(if (= n 0)
1
(* n (factorial (- n 1)))))


In Lisp, operators come first in the list (prefix)

so in Python if you say
(2 + 3)
it is
(+ 2 3)
in Lisp.
Python:
(2 + 3 + 4 + 5)

Lisp:
(+ 2 3 4 5)


Just assume all those paranthesis are not there. You will find it almost like Python
Here is the Lisp version with some paranthesis removed


defun factorial (n)
if (= n 0)
1
* n factorial (- n 1)


How hard is that :)

Long back ago, when i was at the peak of Python craze, i saw Lisp and was quite frustrated by all its (). I then decided that i will not learn this language ever in my life. I was wrong. It seems there are many powerful features which Lisp has, and no other language has. So only way to learn is to learn it :)

Now here is the Python and Lisp version of Tower of Hanoi. Try figure
Python:


def towerOfHanoi (disks, fromp, to, spare):
if disks:
towerOfHanoi (disks[1:], fromp, spare, to)
print "Move %s from %s to %s" % (disks[0], fromp, to)
towerOfHanoi (disks[1:], spare, to, fromp)

towerOfHanoi ([3, 2, 1], 'a', 'b', 'c')


Lisp:


(defun towerOfHanoi (disks from to spare)
(unless (endp disks)
(towerOfHanoi (cdr disks) from spare to)
(format t "Move ~A from ~A to ~A~%" (car disks) from to)
(towerOfHanoi (cdr disks) spare to from)))

(towerOfHanoi '(3 2 1) 'a 'b 'c)