Hacker News new | past | comments | ask | show | jobs | submit login

So are array languages polish notation?

    +/!100
feels like the opposite way you'd write it in some kind of RPN concatenative language

    100 ! [ + ] /



You read it strictly right to left, weird idea to me but it’s common in the array languages - j and APL do it this way too.

I believe the reasoning is something like Iverson (or maybe Whitney) didn’t like the complexity of PEMDAS in maths so decided on this rule.


Iverson wanted consistent symbols and rules for math notation. So it's math first, then programming language next. Makes it extremely strong with describing algorithms, but gets a bit complicated for programming.


In Polish notation all the operators are prefix operators.

In APL family languages there are infix operators and prefix operators.

Prefix operators take as their operand the result of everything to their right. Infix operators take as one operand everything to their right and take as their other operand the first thing on their left.


Not quite. + isn’t the last thing done (which it would be in Polish notation). Instead it’s done during the / operation.

Polish notation would be lisp (or the notion most people have for lisp, special forms and macros break it up a bit).


Lisp is polish notation for trees of variable arity. hence all the parens - you need some way to group them.

So in some K flavoured LISP I think it would be

    ((/ +) (! 100))


Or in clojure with the threading macro

    (->> 100 range (reduce +))
which is equivalent to this, without the macro

    (reduce + (range 100))


yes, quite a bit more long winded than K




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: