Getting Started, Documentation, Tips & Tricks

confused..

Hi guys :)

Currently im learning Lisp and one way was watching the videos from MIT Open Course Ware.. just finished first video and during the course i try to try all the examples by hand and one thing im confused is this:

average of 1.5 and (/ 2 1.5)

from the video it shows 1.3333

but if i use my calculator it should be 1.4166?

im just confused which is indeed correct..

_________________
:Octane: (Sakura) :O2: (Sasuke) :1600SW: (Naruto) ... lil Jesse! (O2 laptop)
“Imagination is more important than knowledge.“ – A. Einstein
Hi Geo, good choice of learning material :)

Are you talking about this video?
http://ocw.mit.edu/courses/electrical-e ... n-to-lisp/

Hal Abelson is an excellent lecturer and he starts the course in very solid ideas. He introduces his subject as Lisp, but it's important to know that Common Lisp is a different language in several important ways from Scheme, the language he uses in the course. Still, there is no introduction to Common Lisp of so high a pedagogical quality, so it's a fine course as long as you know those differences.

In the slide where he shows what happens with SQRT/TRY etc, there is an error. It shouldn't say 1.3333.
[if you use rationals you can see that (* 4/3 3/2) is 2, so 1.3333 isn't any closer an estimate to (sqrt 2) than 1.5 is]. your figure is correct.

_________________
:PI: :O2: :Indigo2IMP: :Indigo2IMP:
geo wrote:
Hi guys :)

Currently im learning Lisp and one way was watching the videos from MIT Open Course Ware.. just finished first video and during the course i try to try all the examples by hand and one thing im confused is this:

average of 1.5 and (/ 2 1.5)

from the video it shows 1.3333

but if i use my calculator it should be 1.4166?

im just confused which is indeed correct..
Actually, you are wrong on both numbers...

Assuming you were referring to "1A Overview and Introduction to Lisp", as lectured by Abelson, in the example where he demonstrated the calculation of the square root of 2, you seem to have missed a few steps, starting with (try 1.3333 2). The final result is indeed 1.4142. In fact, the calculator on my iPhone shows that as well ;-)

BTW, this course is not about (Common) Lisp, but about Scheme - nevertheless, Abelson & Sussman had most probably written the best book on Lisp-like languages ever ["Structure and Interpretation of Computer Programs"]. I still remember that almost 30 years ago upon reading it first it kept me up like a mystery novel :-)
robespierre wrote:
Hi Geo, good choice of learning material :)
Morning robe! hehe thanks, indeed a good choice coz from the beginning i learn terms and techniques..

robespierre wrote:
Are you talking about this video?
http://ocw.mit.edu/courses/electrical-e ... n-to-lisp/
yes! this is it! hehe even if its old still very helpful, only the resolution is a bit low, but good thing is theyh write the words big enough hehe

robespierre wrote:
Hal Abelson is an excellent lecturer and he starts the course in very solid ideas. He introduces his subject as Lisp, but it's important to know that Common Lisp is a different language in several important ways from Scheme, the language he uses in the course. Still, there is no introduction to Common Lisp of so high a pedagogical quality, so it's a fine course as long as you know those differences.
yes i agree on this, also the other professor Gerald Sussman was great and a bit funny type hehe oh! i see, so it means im learning Scheme now which is another dialect hmm thats why when i notice they use DEFINE here but i remember on CL books i read they use DEFUN hmm ok noted with thanks ;) but this still can help me right? btw i noticed they ran the code on a machine, was that machine a LISP machine? so does it mean LISP machine was designed to understand CL and Scheme?

robespierre wrote:
In the slide where he shows what happens with SQRT/TRY etc, there is an error. It shouldn't say 1.3333.
[if you use rationals you can see that (* 4/3 3/2) is 2, so 1.3333 isn't any closer an estimate to (sqrt 2) than 1.5 is]. your figure is correct.
:shock: you got it! thats the part i was refering hehe so its indeed was an error right? thanks for confirming, anyway the example still arrived at the right answer hehe jsut want to clarify myself that our todays computer is doing OK hahaha

Oskar45 wrote:
Actually, you are wrong on both numbers...
Morning Oskar! Oh why so?

Oskar45 wrote:
Assuming you were referring to "1A Overview and Introduction to Lisp", as lectured by Abelson, in the example where he demonstrated the calculation of the square root of 2, you seem to have missed a few steps, starting with (try 1.3333 2). The final result is indeed 1.4142. In fact, the calculator on my iPhone shows that as well
yes2 that it hehe but hmm i think i didnt miss any step coz that error was on the early step where (try 1.5 2) -> 1.3333 :( even robe confirmed its was a mistake :) but yes his final result was correct hehe

Oskar45 wrote:
BTW, this course is not about (Common) Lisp, but about Scheme - nevertheless, Abelson & Sussman had most probably written the best book on Lisp-like languages ever ["Structure and Interpretation of Computer Programs"]. I still remember that almost 30 years ago upon reading it first it kept me up like a mystery novel
ah i see, thats what robes told me too :( but is this still helpfull? :shock: 30 years ago? waaah no wonder my age remindes me of that no. hehe

but yeah, thanks guys for letting me know, i think i just finish this course then use this knowledge to proceed with CL ;)
then later will build my new Lisp machine hahaha

oh did i mention im currently contact Joe Marshall? coz i learn he has the remaining parts of the K-machine? i plan to base it from that design coz it was implemented on RISC.. looking forward for a fruitful endeavor then ;)

_________________
:Octane: (Sakura) :O2: (Sasuke) :1600SW: (Naruto) ... lil Jesse! (O2 laptop)
“Imagination is more important than knowledge.“ – A. Einstein
Geo: I have heard that a functioning workstation based on one of the Scheme-chips was made at MIT, but it wasn't used to teach the intro course. The editor screen shots show a mode-line with the word "Edwin", which is a giveaway that they are using C-Scheme. It ran on Unix, VMS, and DOS, so I can't say for sure which they would have used. (Smart professors probably didn't use DOS if they could help it.)

So to understand why they didn't use Lisp Machines for their course, it's probably enough to say that Lisp Machines were quite expensive ($30-50K in 1986, when the videos might have been produced). But there are other ways that Lisp (including Common Lisp and the dialect named Zetalisp) differ from Scheme, and the most important is something called the Safe-For-Space property by Will Clinger in a 1998 paper.

When Abelson says that you really don't need control structures like FOR loops, he is right in the sense that they can all be expressed by clever use of functions (he calls them procedures). But to write an infinite loop with recursive functions, it needs to be safe to call functions infinitely deeply. The only way to do this safely is to use a different method of temporary storage from the conventional stack, since stacks grow each time a new function is called, and eventually the address space (or the virtual memory device) would become exhausted. Scheme implementations instead put their "frames" on the heap and make them garbage-collectable like other data. So as we keep calling functions infinitely deeply, the "frames" that we will never return to become orphaned and get swept away by the collector, keeping memory from running out.

Lisp machines that ran systems like Genera were designed differently, with the stack being a fundamental part. So if your function is infintely recursive, what will happen is that eventually the stack will exceed its limit and a SERIOUS-CONDITION will be flagged. There are ways to compile Scheme code on lisp machines and other CL systems, but they don't have the important Safe-For-Space property.

_________________
:PI: :O2: :Indigo2IMP: :Indigo2IMP: