Thread: SciFi history?
View Single Post
Old 07-27-2010, 09:32 AM   #113
kacir
Wizard
kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.
 
kacir's Avatar
 
Posts: 3,463
Karma: 10684861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
Quote:
Originally Posted by mike_bike_kite View Post
I used your 17 x 25 as an example. My son looked on while I carefully adjusted the bars to show him how clever it all was. Sadly he'd worked out the answer in his head before I'd managed to get the result. He's 13 - I suppose there's some hope left
Next time, if you get another chance ;-), use something like 1.37*pi*7.15/sqrt(20) (after demonstrating 2*3 and 7*8 to show the principle)
Quote:
Originally Posted by mike_bike_kite View Post
The idea of RPN is that you don't need parenthesis however LISP is famous for requiring thousands of the damn things - what gives?
Well, it is difficult to explain in a few lines, but in Lisp EVERYTHING is either a list or an atom. A list consists of atoms or other lists. Even the program listing is one top level list, containing other lists or atoms. List (or an atom, that can be a value, variable or a keyword) is the only thing that LISP can process. So the program written in LISP can be used to modify itself. Or you can build a list into variable and then execute it as a "function".
Parentheses (together with the necessary whitespaces separating atoms) are the only thing that determine the structure of LISP program.
Lisp is beautiful language. Very simple, very capable, the interpreter can be written with absolute minimum of code. This is why Lisp and its descendants (very often carefully disguised, so it is not obvious that "gee, this is that scary Lisp") are so popular as an embedded language for many systems.

(+ 1 2) gives answer 3
(* (+ 1 2) 4) gives answer 12
On an RPN calculator you would enter something 4 shift 2 shift 1 + *
But depending on the depth of the stack you do need to use parenthesis if the level of the deepest nested parenthesis is high enough.

For better example have a look at this Wikipedia article
http://en.wikipedia.org/wiki/Lisp_%2...ge%29#Examples

When you write a program in AutoLisp and you want to prevent other people from reading the program you simply strip all the CR/LF characters (make it one long line), replace tabs (used for formatting) with spaces and then replace every occurrence of more than one consecutive space with one space. When you replace all the variable names with some A1, A1, A3, B1 meaningless names, it is guaranteed that nobody will be able to understand your program without LOTS of effort, especially when the program is long ;-)

so a nicely formatted
Code:
 (defun factorial (n)
   (if (<= n 1)
       1
       (* n (factorial (- n 1)))
    )
)
becomes
Code:
 (defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))
Now imagine that you are a programmer in the early stone age of programming and you use very simple editor without parenthesis matching function and you need to make sense of the VERY SHORT and simple example above ;-)

By the way, do you know the GNU Emacs text editor?
Do you know it has absolutely magnificent built-in RPN calculator that can find root of the equation of the n-th power, solve system of n non-linear equation with m variables in symbolic notation and do other unbelievable things?
kacir is offline   Reply With Quote