Here is a simple scheme program to generate prime numbers in scheme.
;Written by Fakrudeen Ali Ahmed
;Date 9 January 2007
;primes above a bound
(define (primes-above n count)
(define (loop k count)
(if (= count 0) '()
(if (prime? k) (begin (display k) (newline) (loop (+ k 1) (- count 1))) (loop (+ k 1) count))))
(loop n count)
)
;primes less than n
(define (primes-less-than n)
(define (loop k)
(if (= k n) '()
(begin (if (prime? k) (begin (display k) (newline))) (loop (+ k 1)))))
(loop 2)
)
;whether n is prime?
(define (prime? n)
(cond
((or (= n 2) (= n 3)) true)
((or(= 0 (remainder n 2)) (= 0 (remainder n 3))) false)
(else (let ((limit (expt n (/ 1 2))))
(define (loop k)
(let* ( (j (- (* 6 k) 1) ) (l (+ j 2)) )
(cond
((< limit j) true)
((or(= 0 (remainder n j)) (= 0 (remainder n l))) false)
(else (loop (+ 1 k))))))
(loop 1)))))
Friday, December 29, 2006
Godel's theorem!
Godel proved there are true statements, whichever are unprovable!!
Isn't interesting?
That forever dashes the hope we can prove all mathematical facts.
http://en.wikipedia.org/wiki/Kurt_G%C3%B6del
It also has interesting consequences for what we can calculate algorithmically.
Isn't interesting?
That forever dashes the hope we can prove all mathematical facts.
http://en.wikipedia.org/wiki/Kurt_G%C3%B6del
It also has interesting consequences for what we can calculate algorithmically.
IBM developerworks!
If you are developer this site is a "must" see.
developerWorks : IBM's resource for developers [ http://www.ibm.com/developerworks/ ]
They also have a weekly newsletter.
developerWorks : IBM's resource for developers [ http://www.ibm.com/developerworks/ ]
They also have a weekly newsletter.
Wednesday, December 27, 2006
Wikipedia!
I love these folks!
http://wikipedia.org
This is the the first place I search to know about something!
http://wikipedia.org
This is the the first place I search to know about something!
Tuesday, December 26, 2006
style preview in word
New Microsoft word has a nice live preview of style. Select a block of text and just move the cursor over style boxes on top and see!
Monday, December 25, 2006
Perumazhakkalam (പെരുമഴക്കാലം)
If you like watching good movies in Malayalam, Perumazhakkalam (പെരുമഴക്കാലം) is surely one. Different story. Watch it yourself!
Sunday, December 24, 2006
Blank slate!
A very good book about biology/human nature.
It argues that root of most of our behaviours are due to our genes.
Makes you realistic [as opposed to optimist or romantic]!
It argues that root of most of our behaviours are due to our genes.
Makes you realistic [as opposed to optimist or romantic]!
Saturday, December 23, 2006
prefix vs postfix -- operator
I realized if I have a choice I should use prefix -- instead of postfix.
int findLength(const Node* list) {
int count = 0;
for(const Node* current = list; count++ < current =" current-">getNext()) {
}
return count--; //<-------------- bug
}
This is a bug [which compiler doesn't warn either] - what is the point of incrementing a local variable after it is returned!?
--count here works fine and is correct.
int findLength(const Node* list) {
int count = 0;
for(const Node* current = list; count++ < current =" current-">getNext()) {
}
return count--; //<-------------- bug
}
This is a bug [which compiler doesn't warn either] - what is the point of incrementing a local variable after it is returned!?
--count here works fine and is correct.
Friday, December 22, 2006
C runtime source!
C runtime source is available with visual studio installation. It is very useful say for checking how malloc is implemented.
It also has nice and tested algos. for strncpy etc.
It also has nice and tested algos. for strncpy etc.
Thursday, December 21, 2006
Clippool
It is a cool utility to copy from one computer and paste in another computer: http://support.microsoft.com/kb/318760
Tuesday, December 19, 2006
Google earth!
I love it - particularly look at its driving directions!
I just don't want to close this!
[Make sure you have hardware acceleration set to full for display to avoid directx problems]
I just don't want to close this!
[Make sure you have hardware acceleration set to full for display to avoid directx problems]
Monday, December 18, 2006
string comparisons in .NET
This article is very good for understanding ordinal vs invarint vs current cultures in .NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/StringsinNET20.asp
Saturday, December 16, 2006
Startup programs
Here is an interesting link I found about [disabling!] startup programs:
http://www.pacs-portal.co.uk/startup_index.htm
http://www.pacs-portal.co.uk/startup_index.htm
Sunday, December 3, 2006
edge
If you like to reflect [in the metaphysical sense] a bit, this is a nice site to do that:
http://www.edge.org/
Particularly have a look at world question center. It has answers for a "big" question from eminent people at the start of every year.
http://www.edge.org/
Particularly have a look at world question center. It has answers for a "big" question from eminent people at the start of every year.
Saturday, December 2, 2006
Thinking in Java!
One of the best books for learning Java is this: Thinking in Java.
What's more, its free from Bruce eckel's site.
http://www.mindview.net/Books/TIJ/
What's more, its free from Bruce eckel's site.
http://www.mindview.net/Books/TIJ/
Thursday, November 30, 2006
Tuesday, November 28, 2006
ponder this...
If you are interested in great puzzles/mathematical problems here is a great site:
www.research.ibm.com/ponder/
www.research.ibm.com/ponder/
Monday, November 27, 2006
Videos on consciousness!
Here is a great link of videos on consciousness and philosophy:
http://broodsphilosophy.wordpress.com/2006/06/15/online-videos-of-philosophical-lectures
http://broodsphilosophy.wordpress.com/2006/06/15/online-videos-of-philosophical-lectures
Saturday, November 25, 2006
Running 10K
In case you want some sort of crude amateur bench mark for practicing 10K run:
I could run with 2 weeks practice:
6km in 38 minutes at ~10km/hr [6.6 including cooldown in 43 minutes]
7.5 km in 50 minutes at ~9km/hr [8.5 including cooldown in 1 hr]
I could run with 2 weeks practice:
6km in 38 minutes at ~10km/hr [6.6 including cooldown in 43 minutes]
7.5 km in 50 minutes at ~9km/hr [8.5 including cooldown in 1 hr]
Friday, November 24, 2006
Thursday, November 23, 2006
தமிழ் windows
If you want your windows in தமிழ் you can install this software from this link:
http://www.microsoft.com/downloads/details.aspx?FamilyId=0DB2E8F9-79C4-4625-A07A-0CC1B341BE7C&displaylang=ta
I have it on my computer.
http://www.microsoft.com/downloads/details.aspx?FamilyId=0DB2E8F9-79C4-4625-A07A-0CC1B341BE7C&displaylang=ta
I have it on my computer.
Wednesday, November 22, 2006
Road to reality
If you want to learn a lot of physics, 'Road to reality' is the book for you.
It will take a lot of time to complete though. But it is a great book.
It will take a lot of time to complete though. But it is a great book.
Tuesday, November 21, 2006
Selfish gene
One of the best books I have read - [converted me into an atheist!] - This book is about evolution. This book says we [all animals] are survival machines built by our genes for their survival! Very interesting, a bit depressing for the first time readers.
I think every one should read this.
I think every one should read this.
Monday, November 20, 2006
Great physics courses online
if you are interested in physics and want to actually learn it - this is something you want to look at:
http://ocw.mit.edu/OcwWeb/Physics/8-01Physics-IFall1999/VideoLectures/index.htm
http://ocw.mit.edu/OcwWeb/Physics/8-01Physics-IFall1999/VideoLectures/index.htm
Friday, November 17, 2006
IE7 vs firefox 2.0
If you are confused between upgrading to IE7 and firefox2, Here is one reason to pick IE7:
It installs some nice cleartype font, reading from computer looks so pleasing even for other applications.
It installs some nice cleartype font, reading from computer looks so pleasing even for other applications.
Subscribe to:
Posts (Atom)