No this isn't a joke, or a meme or a fad or whatever you think it is. It just a
regular programming problem.
I'm making a ASCII-art math generator. So you can input in your document
Maxima-notation math and get a corresponding representation. Example:
>Integrate(x^2,x,0,5)
5 __
/ 2
_/ x dx
0
While a got the AST right. When making the representation on ASCII-text I hit a
problem. The inner-term can change the structure of the outer ones, so this
isn't straight forward
>integrate(x,x,0,5)
>integrate(x+3/2,x,0,5)
5 __
/
_/ x dx
0
5 ______
/ 3
/x + - dx
_/ 2
0
Which is the simplest approach to this?
Pd: I am not telling in what I'm implementing it so it doesn't derail.
Name:
Anonymous2012-04-18 20:53
Hey, can anyone else post new threads? I keep getting an error every time I try.
Sorry OP, I don't know the answer to your problem.
I get the message "A fatal error occurred! Thread ID specified does not exist." followed by what I wrote.
I'm clicking the "Create new thread" button at the bottom of the page, but this happens every time. I don't want to hijack someone else's thread for my own question. I can still reply, though.
Name:
Anonymous2012-04-18 21:11
OP, do you mind if I hijack your thread for a few posts? It's a really simple problem, probably. I'm new to Java, and programming in general.
Hey /prog/, I'm trying to make a program that displays a base to an exponent, and all exponents before it. Here's where the line screws up.
for (i = exponent; i <= 10; i--) {
outputField.setText(base + " to the exponent " + i + " = " + Math.pow(base, i) + "\n");
}
So if someone were to say 2 for base, and 6 for exponent, it would show 2^6 all the way down to 2^1 in a sequence. Unfortunately, it just freezes instead. exponent and base are set as int, so that should make i an int too, right? Is the problem that it's trying to solve for every number equal to or less than 0?
Name:
Anonymous2012-04-18 21:20
>>1,3
Shared IP? If I post a reply, I can't make a thread for a while. Perhaps it is someone else making a post to /prog/ when you try to make a thread?
>>6
That's what I read online, but I've tried refreshing and posting again multiple times, and I know no has posted in between, and each time the error comes up.
By shared IP, do you mean someone else in my house is doing something here? Because I REALLY doubt that. Or I could be misinterpreting what you're saying.
>>14
So it's making it difficult to accept end-to-end connectivity?
I don't think I have one (if I'm getting the gist of this correctly).
Name:
Anonymous2012-04-18 22:13
>>15
hum check the server response and browser request, webdeveloper/fiddler/firebug or a packet tracer should do the job
>>5
what do you mean "screw up"? exception? warning on compilation? wrong output?
Name:
Anonymous2012-04-18 22:15
ONE MORE FINAL
Geh, I've just about figured it out.
for (i = exponent; i >= 1; i--) {
outputField.setText(base + " to the exponent " + exponent-- + " = " + Math.pow(base, exponent) + "\n");
}
When I put
System.out.println(base + " to the exponent " + exponent-- + " = " + Math.pow(base, exponent));
It shows up correctly, but when I try to get it to show in the text box, it only does the last line. How would I go about getting it to show the others? Also, how could I rearrange the order so it shows ^1 first instead of last? It's counting backwards, not forwards.
Name:
Anonymous2012-04-18 22:21
oh...so it only shows the last line...simply put, the fieldset has an associated buffer, when you call setText you SET the contents of that buffer, when you call println you APPEND something to some buffer, in this case to a file stream shown somewhere
why are you using something graphical if you didn't get there yourself
Name:
Anonymous2012-04-18 22:30
>>18
Because I'm a moron, and my teacher just says that's what he wants. We used println for the very first assignment way back when, and then started using graphics. He didn't explain much about how they work.
I really wish he explained programming terminology, because every time I look some up, it explains it in more terminology I can't understand, and the cycle continues. I feel like an idiot.
Name:
Anonymous2012-04-18 22:39
>>18
Oh yeah, I forgot to ask, does that mean I can't use setText()?
>>1
Well what I think would be the simplest way would be to track the vertical bounds of the notation based on the expression and the rules of the notation. Getting the program to resolve to the correct value for the vertical bounds of every expression is an exercise left to the breeder.
░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▄▄░░░░░░░░░
░░░░▄▀▀░░░░░░░░░░░░░▀▄░░░░░░░
░░▄▀░░░░░░░░░░░░░░░░░░▀▄░░░░░ YOU HAVE BEEN VISITED BY
░░█░░░░░░░░░░░░░░░░░░░░░▀▄░░░ LE 'FEEL OF NO GF
░▐▌░░░░░░░░▄▄▄▄▄▄▄░░░░░░░▐▌░░
░█░░░░░░░░░░░▄▄▄▄░░▀▀▀▀▀░░█░░ A qt 3.14 gf will come to you,
▐▌░░░░░░░▀▀▀▀░░░░░▀▀▀▀▀░░░▐▌░ but ONLY if you post a
█░░░░░░░░░▄▄▀▀▀▀▀░░░░▀▀▀▀▄░█░ `>tfw no GF on this thread
█░░░░░░░░░░░░░░░░▀░░░▐░░░░░▐▌
▐▌░░░░░░░░░▐██▀█▄░░░░░░█▀█░▐▌
░█░░░░░░░░░░░▀▀▀░░░░░░▀▀▀▀░▀▄
░▐▌░░░░▄░░░░░░░░░░░░░▌░░░░░░█
░░▐▌░░▐░░░░░░░░░░░░░░▀▄░░░░░█
░░░█░░░▌░░░░░░░░▐▀░░░░▄▀░░░▐▌
░░░▐▌░░▀▄░░░░░░░░▀░▀░▀▀░░░▄▀░
░░░▐▌░░▐▀▄░░░░░░░░░░░░░░░░█░░
░░░▐▌░░░▌░▀▄░░░░▀▀▀▀▀▀░░░█░░░
░░░█░░░▀░░░░▀▄░░░░░░░░░░▄▀░░░
░░▐▌░░░░░░░░░░▀▄░░░░░░▄▀░░░░░
░▄▀░░░▄▀░░░░░░░░▀▀▀▀█▀░░░░░░░