Tuesday, February 5, 2008

I am writing a compiler to learn Computer Science better (Stevey influence). People suggested that I write an interpreter first and slowly expand from there. I am playing with writing few text transformation programs. It is fun.

I am reading "The Little Schemer" book. So naturally, I am trying to solve things by writing recursive functions... with equivalents of CAR, CDR, CONS etc.

Program input:
"1,2-5,7,10-14"

Program output:
[1,2,3,4,5,7,10,11,12,13,14]

I wrote this as the first step: Program 1

Today: Feb 06, 2008
I wrote this instead: Program 2. It is a complete program that produces the above mentioned output. I didn't use any recursion or functional programming ideas. I just wrote a "as simple as possible" python program. Just wanted to start the day with a working program. I'll rewrite it the car-cdr way soon. I actually wanted to write in Lisp but didn't know to car-cdr strings. I should learn that.

Notes:
What if the paste-bins I linked to go away? I should set up my own paste-bin. [Update #1: the pastebin site I used is open source. I should install it in my website.] [Update #2: Created a 'private' pastebin on the site... kiru.pastebin.com]

No comments: