« first day (1093 days earlier)      last day (3019 days later) » 

1:01 AM
@JimmyHoffa but that one seriously went in a bookmark folder marked "TO READ"
1:22 AM
What you are looking for is a calculator parser grammar (a simple approach is unlikely to work). You will likely find yourself using something along the lines of ANTLR - doing this correctly is a non-trivial task without understanding parsers. — MichaelT 20 mins ago
@MichaelT c'mon, a basic calculator parser is really really trivial.
If you know how to write a parser.
It also requires you think about what you are trying to parse. n*3/7+9-5 can be parsed in at least two ways. And I think he's not got the full equation there either.
Then you start getting into inconsistent formats...
IE they will be of the type x^2 + x + 1 not x + x^2 + 1 — AdamG 1 hour ago
@AdamG, no, they are from the user, so I can not promise that. — Ari Porad 1 hour ago
1:35 AM
@MichaelT A basic calculator parser is pretty trivial, string manip and parsing is like step 1 in learning to program (isn't it?). It's just a super simple NDFA switch(char){case '+': state bla; case '-': state bla;} etc
granted I didn't look at the guys question to see how far down the totem pole he is...
Basic basic, if you're not worrying about order of operations or parentheses... yes.
@MichaelT You can even get a general sense of order of operations if imperfect like that
He's working with exponents, something that looks like a variable, order of operations...
9 + 3 / 4 Without order of operations is 3. With order of operations, its 9.75
well...*I wouldn't have much trouble with it*... heh therefore, it's err, easy?
1:38 AM
And thats an easy one. Lets do 9^3 * 4. Does the multiplication bind to the exponent? or the result?
@MichaelT do a first pass to add parentheses around the terms being exponentiated, then a pass to parenthesize terms being multiplied or divided left to right, then terms being added or subtracted left to right, then pass the string to a recursive descent NDFA that just follows the steps per parenthetical definition.
that's...fairly basic...
...I'll shutup now...
And the guy is looking to do a simple one pass string manipulation to get something that I don't even know what he's trying to get out of it...
@MichaelT You might be able to find proof it's a context sensitive grammar and cannot be parsed without backtracking or multiple passes and just dash his hopes with some citations
(I don't know if that's accurate to say about context sensitive grammars as a whole, but in this case I believe it might be)
(1+(2*(3+4))) requires backtracking or multiple passes
I've figured out the 4 and 3/7... and its still awkward.
(n*3/7) + (9-5) gives the 0th and first for n. This implies parsing and resolving the information... the key being parsing. Which is what he needs to do.
1:47 AM
there is no way to parse that with a single pass without backtracking
It involves restricting the grammar... but you could have an accumulator for each n^x.
@MichaelT Is he trying to parse a single specific statement? that would be easy, but if it's general information, as soon as you nest parentheses you must backtrack or make a second pass.
@elclanrs, I need them like this so I can put them in a db and easily avoid duplicates. — Ari Porad 3 hours ago
Arbitrary user entered statements.
@MichaelT Ooo he could use the parser combinator library I wrote in JavaScript...
1:51 AM
I see that 'p' word again.
haha is he specifically trying to not parse?
He doesn't know he needs to get to the level of a CFG. I don't think a regex would handle it nicely.
@MichaelT Got my SO close vote
There are SO votes on there?
2 of them actually
You linked me to SO
Q: Javascript - Parse Polynomials From String

Ari PoradI Just Asked this question for objective-c here, but need the answer quick and am able to do the parsing in either objective-c or javascript, so I will ask for js here. In my app the user will be inputting a mathematical expression as a string, such as n*3/7+9-5, and I need to be able to get the...

Q: Objective C - Parse Polynomials From String

Ari Porad I Am building an iOS app in which the user will enter a string, such as n*3/7+9-5, and I need to get the polynomial from that string, such as 4, 3/7, 0, 0, 0, 0. Is there an y way to do this in objective-c? The result could be a string or an array, I don't care. Also, I have been using DDMathPa...

1:54 AM
I don't see how you get the 4 or 0s in there. Secondly, this post is a duplicate / cross post of Javascript - Parse Polynomials From String and Objective C - Parse Polynomials From String from Stack Overflow. — MichaelT 54 mins ago
There's all three links.
Heh on SO he has one -1, and one +1/-1 and one close vote each. On P.SE he's at -4 with 3 close votes.
sorry 2 close votes each on SO now.
One guy gave him a lexer for it... that should do a reasonable job.
If you would like, I could just give you tEh c0dez, is that what you want? To have a professional who works 9 to 5 to just pencil you in as a deserves-free-help-without-even-trying? I'll get right on that, but do me a favor and read the source code here first, you might find it enlightening: github.comJimmy Hoffa 10 secs ago
...just read all of github, then I'll go ahead and give you teh c0dez...
As much as I agree with the sentiment... I feel the snark on that might be just a bit high...
2:02 AM
@MichaelT perhaps, deleted. and I edited the lexer answer to make clear that code is not authored by the answerer; it's just straight from the link he posted
8 hours later…
10:19 AM
is anybody here?
10:36 AM
im about to get takeaway tho. but ill be back
5 hours later…
3:24 PM
@JimmyHoffa I don't think that quite works.. With SK calculus's K, K x y = x, and x and y are independent, with a reader monad, you could have ask :: Reader a a
Not independent anymore
I intuitively think about it as more of a way of combining function bodies, eg f = \a -> b, g = \a -> c, f >> g === \a -> b seq c
8 hours later…
11:23 PM

« first day (1093 days earlier)      last day (3019 days later) »