Back to News
Advertisement
Advertisement

⚡ Community Insights

Discussion Sentiment

0% Positive

Analyzed from 260 words in the discussion.

Trending Topics

#algorithm#parsing#should#token#train#input#something#start#mobile#site

Discussion (10 Comments)Read Original on HackerNews

rembicilious3 minutes ago
If I start the train and then type a nested bracket expression like 2+(2-(3/5)) the train jumps the track
pimlottc11 minutes ago
I can’t figure out how to make it start processing the input on mobile Safari, am I missing something?
dcrazy7 minutes ago
Drag the speed slider to the right.
alter_igelabout 1 hour ago
I'm not familiar with the algorithm and I don't see much explanation on the site (at least on mobile) but AFAICT this is turning parenthesized infix expressions into reverse Polish notation. In other words, it takes human-readable mathematical formulas and converts them into something a simple stack-based machine can compute in one forward pass.

It also appears that separate digits aren't interpreted as decimal numerals (i.e. (1)(3) is the sequence 1,3 and not 13) which can look a bit misleading.

justinpombrioabout 1 hour ago
Yeah, it's a parsing algorithm for parsing infix (etc.) expressions. If you've seen a parsing library refer to "precedence climbing" or "operator precedence parsing", it's doing this (or something very similar).

If you want to enter the number `13`, that should be one token, but there's no way to make a `13` token in this UI. You need to stick to single digits for this site to work correctly.

abd-nhabout 1 hour ago
I made a basic demo of this years go: https://abdnh.github.io/shunting-yard-algorithm-demo/
dcrazyabout 2 hours ago
I typed `100+88/4` and the resulting output was `100884+/`. Should the algorithm be inserting a symbol to delineate operands?
justinpombrioabout 1 hour ago
It treated that as

    1 0 0 + 8 8 / 4
which is nonsensical, but it has no error detection so it rolled with it. Really `100` should be its own token, but there's no way to input that.
dcrazy6 minutes ago
How would one typically implement this tokenization? Pre-pass on the input? My initial thought was to push an operand-terminator token when encountering an operator, but it was unclear to me whether it should be pushed to the stack or the output.
IIAOPSWabout 2 hours ago
Hold up. you can't just have the train take the parenthesis off screen and hand wave away what happens to those cars. What happens when your forced to keep the garbage of a computation because you can't delete anything?

(https://en.wikipedia.org/wiki/Reversible_computing)