So, if 2 5 8 5 - × + is “RPN” does that mean that the LISP version is Polish Notation?
Comment on I dunno
vala@lemmy.dbzer0.com 11 months ago
(* (+ 2 5) (+ 2 5))
Hope some LISP can clear this up
merc@sh.itjust.works 11 months ago
Reginald_T_Biter@lemmy.world 11 months ago
Explain yourself sir
vala@lemmy.dbzer0.com 11 months ago
This is called “prefix notation”. The operator comes before the operands and every expression goes in parentheses.
For instance you could write:
(+ 1 2 3 4)
Which would evaluate to 10.
This syntax is from a family of programming languages usually called LISP.
merc@sh.itjust.works 11 months ago
Also, you can use this for more than just arithmetic. The first thing in the list is the name of the function, and everything else is something that you pass to the function. So you could instead write
(plus 1 2 3 4)
Which would be like
plus(1, 2, 3, 4)in other kinds of programming languages.Reginald_T_Biter@lemmy.world 11 months ago
Awesome thanks for explaining that. That’s cool as hell.
call_me_xale@lemmy.zip 11 months ago
I understand prefix notation, but you got the order of operations wrong…
yboutros@infosec.pub 11 months ago
Is this a meme? Shouldn’t it be
vala@lemmy.dbzer0.com 11 months ago
Damn you are right haha.
Mine evals to 21.