Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Prog i need your wisdom

Name: anonymous coward 2012-04-18 20:44

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: Anonymous 2012-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?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List