Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help. Please help me!!!! Please Help
#11
Quote:Is that a goto I see?! :barf:

manifestnolimit4ya: please, PLEASE do not EVER use goto! Goto is terrible programming practice (unless you love spaghetti code), and you can always replace goto with another construct. ALWAYS.

For this particular problem I would suggest using FUNCTIONs and maybe TYPEs as well.
Three words:

GET OVER YOURSELF.
\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Reply
#12
We all know thegrogen is incorrect on several counts, no need to start a flame war.

Oops.... :lol:
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#13
A bunch of years ago (like 1993??!!??) I was taking calc. and I wrote some programs to integrate functions (not differentiate). The way I dealt with it (since is was BASIC, a *translated* language) was to make the function part of the code. Since it is translated, and I was only writing code for myself, it was painless to put the function into the code. What I then did was hard code the limits of the integration and run to evaluate. I sliced the limits into something like 32K slices, and ran. I'd quickly get a numeric value that I could compare with the theoretical value. Worked fine for all functions I tested over reasonable limits. I also made some plotting functions, that displayed the functions, but they weren't particularly useful.

differentiating numerically is simerally easy...give the function then step through it in small increments (for x = i to f step 0.0001). Then take the difference at each step and plot it.

This won't give an equation bit gives numerical answer that is easy to evaluate to get the key data (eg inflection points) from.

You have to learn arrays in either case, in case you don't already know how to use them, which is valuable in itself.

Using computers to achieve numerical answers to integral calc. problems is of great use and also a great way to learn more about programming. Cheers, and great encouragement. The problem you are solving happens to be one of the ones that computers are best at solving.

If you are looking for the integral of a particular equation in the abstract (ie not a numerical answer, an equation) check out Wolfram's site. He has a site that solves integrals. It's really cool, if you "get" it.
Reply
#14
Languages like QB make this task very ugly, inefficient and painfully tedious. But if you're up for it, what you're looking to create is an Expression Tree, and you should do some searching to get all the juicy details about them.

NOTE: languages like FB, C and others that support pointers and dynamically allocated memory can create expression trees quite easily.
stylin:
Reply
#15
Stylin, I disagree.

Don't rant about expression trees with pointers please. QB, FB, and many other Basic language compilers are perfectly capable of making this function work.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#16
'Capable' and 'practical' are two different concepts, as are 'working' and 'extensible'. I figure I'd give the OP additional options to consider, and also introduce a different way of looking at the problem. I'm aware expression trees aren't the only way to go about this - in fact I've been writing an implementation in FB using stacks; no pointers, just dynamic string function arguments. If you'd like, I'll also code a version using expression trees, and we can compare and contrast ?
stylin:
Reply
#17
Quote:We all know thegrogen is incorrect on several counts, no need to start a flame war.

Oops.... :lol:

Heh, I just got back from the C++ camp... let me tell you, over there they grind into your head that you cannot use goto for any reason whatsoever. I can see where they're coming from, too.

I will admit that sometimes goto is faster, but for the most part, goto makes your code look like crap (although this may be different nowadays in QB/FB, I haven't been using it for a while so I wouldn't know).

Show me a valid use of goto that cannot be duplicated with another code structure, and I will desist.

I stand by my original suggestion, using FUNCTIONs, as with those the OP will be able to easily reuse his code.
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply
#18
Yes, but it is often easier to use GoTo. It's only a problem if you are using GoTos constantly, such as in a loop. Not all GoTos cause spaghetti (aye, the spelling) code.
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#19
Quote:Show me a valid use of goto that cannot be duplicated with another code structure, and I will desist.
Nested inner loops is always a good one:
Code:
for i = 0 to 10
   for j = 0 to 10
      for k = 0 to 10
         if( some_condition ) then goto exit_loops
      next k
   next j
next i

exit_loops:
stylin:
Reply
#20
Quote:
thegrogen Wrote:Show me a valid use of goto that cannot be duplicated with another code structure, and I will desist.
Nested inner loops is always a good one:
Code:
for i = 0 to 10
   for j = 0 to 10
      for k = 0 to 10
         if( some_condition ) then goto exit_loops
      next k
   next j
next i

exit_loops:

Code:
for i = 0 to 10
   for j = 0 to 10
      for k = 0 to 10
         if( some_condition ) then
            i = 10
            j = 10
            k = 10
         end if
      next k
   next j
next i

Not sure if that will work, I'm on a school computer right now, but that's one solution.

edit: I changed it so that it would be a bit more readable.
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)