Log in

View Full Version : Help with masktools + RPN?


Sagekilla
20th October 2008, 06:08
I'm trying to learn masktools but I can't figure out for the life of me how to do the reverse polish notation.

What I wanna figure out is how I would do something like: (x < 20) ? x + 20 : x

Except, I went and tried to read masktools documentation (and look up RPN online) but I haven't found any help regarding this at all.. Can anyone instruct how I would properly do ternary operators or boolean operators? :)

thetoof
20th October 2008, 06:30
A great tool to learn how it works is to write your infix expression in a mt_polish call.
subtitle(string(mt_polish("(x < 20) ? x + 20 : x")))
Result: x 20 < x 20 + x ?

Fizick
20th October 2008, 14:40
so, why not revert all masktools polish style to usual ternary? (may be option "polish=false")
It is a task for MaskTools 2.1 development ;)

Sagekilla
20th October 2008, 18:56
Oho, you'll be implementing the standard infix notation soon? Great to hear :) I like the idea of RPN, but it's sort of.. unusable for me right now.

Fizick
20th October 2008, 19:32
No, me not :)

Adub
20th October 2008, 20:53
Talk to Manao about it.

IanB
20th October 2008, 21:44
Oh geezzzz, just use the MT_POLISH call in the other MT_* functions. Write a wrapper function if it helps.

pbristow
20th June 2011, 16:59
Another quicky on the RPN in masktools: Is there an operator to duplicate the top stack entry? I couldn't find one, but I'm hoping I've just overlooked the obvious.

For example, to calculate the square of (x - y), do I have to use "x y - x y - *", or is there an option of "x y - dup *"?

(I suppose there's always "x y - 2 ^", but that goes against the grain somehow... :) )