[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is perl still the No.1 language for sysadmin?





On 4/8/23 08:19, Emanuel Berg wrote:
Tom Dial wrote:

Look at the use of parentheses in Lisp [...]

I have thought about that - is Lisp possible without them?
But how do you then know priority? I'm sure someone tried
to get rid of them, but how?

Its quite a few years since I had anything to do with Lisp,
and even more since I wrote my Symbolic Logic final using
parenthesis-free Polish notation (i.e., Reversed RPN).

Yes, you mean instead of

   (* 1 2 (+ 1 2 3) 3)

How would that look?

1 2
   1 2 3 +
   3 *

?
Following Lukaciewicz,
  * * * 1 2 + + 1 2 3 3

Evaluation:
  * * * 1 2 + + 1 2 3 3 =>
  * * * 1 2 + 3     3 3 =>
  * * * 1 2 6         3 =>
  * * 2     6         3 =>
  * 12                3 =>
  36

	or

  * * * 1 2 + + 1 2 3 3 =>
  * * 2     + + 1 2 3 3 =>
  * * 2     + 3     3 3 =>
  * * 2     6         3 =>
  * 12                3 =>
  36

With RPN:
   1 2 1 2 3 + + 3 * * *

Evaluation:
   1 2 1 2 3 + + 3 * * * =>
=> 1 2 1     5 + 3 * * * =>
=> 1 2         6 3 * * * =>
=> 1 2            18 * * =>
=> 1                36 * =>
=> 36

'*' and '+' are binary operations. The simplified version '1 2 1 2 3 + 3 *' is ambiguous without the sort of stop rules that parentheses provide in Lisp. It is less than obvious how to provide for N-ary operations with N > 2. One, maybe the simplest, is shown above.

Regards,
Tom


Reply to: