Thread: Expression Manipulator v0.2 (bug fixes, functions)

  1. #1
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490

    Expression Manipulator v0.2 (bug fixes, functions)

    Here's the source code. I'll upload an executable a short while later (in the morning, likely).

    New Features:
    - functions: 6 constant trig functions, log functions, and any number of user-defined functions
    - new subtraction rules
    - all known bugs fixed

    Features:
    - 4 regular functions plus raising to a power
    - boundless limits on name sizes and recursion
    - simplification functions


    Usage:
    Code:
    sin(cos(0))*3+4(5-x)^3
    Output:
    Code:
    3*sin(cos(0)) + 4*[5 + -1*x]^3 = 3*sin(cos(0)) + 4*[5 + -1*x]^3
    
    3*sin(cos(0)) + 4*[5 + -1*x]^3 = 3*sin(cos(0)) + 4*[5 + -1*x]^3
    3*sin(cos(0)) + 500 + -300*x + 60*x^2 + -4*x^3 = 3*sin(cos(0)) + 500 + -300*x +
    60*x^2 + -4*x^3
    2.52441 + 500 + -300*x + 60*x^2 + -4*x^3 = 2.52441 + 500 + -300*x + 60*x^2 + -4*x^3
    6 trig functions:
    sin, cos, tan, cot, sec, csc
    2 log functions:
    log - base 10
    ln - base e

    f() is defined to be f(x) = x+y, although it could be any expression.
    Code:
    f(3)g(3)
    would become
    (3+y)*g(3)
    Comments? Questions? Suggestions? (Just fyi, terms aren't combined at the end, though nothing prevents them from being combined)
    Last edited by ygfperson; 05-26-2003 at 12:07 PM.

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    Here's the executable, source code, and all:

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    I take it you've removed the bugs you wanted me to look at?
    My best code is written with the delete key.

  4. #4
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I keep trying to type in equations but it closes the window and there are no discernable results (what am I doing wrong? I tried typing expressions similar to the example you gave). I've been looking through the source, it looks really cool I wish I'd written it. Did it take ya a long time to write? What was this project for? Fun? School? Get laid?

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    Originally posted by Prelude
    I take it you've removed the bugs you wanted me to look at?
    lol... yeah...

    Turns out I was using a reference where I should have used a local copy of the variable. My substitute function inputted a const reference to compare each copy in the vector with; but that reference was replaced during the for-loop, crashing the program.

    I keep trying to type in equations but it closes the window and there are no discernable results
    You need to run the program from a command prompt. Windows closes the window before you have a chance to see what the result was.
    I've been looking through the source, it looks really cool I wish I'd written it. Did it take ya a long time to write?
    Around 2 or 3 months... but I only worked on weekends and for a few hours at a time.
    What was this project for? Fun?
    Yes.
    School?
    No.
    Get laid?
    I wish.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Attaching functions to a class/struct
    By VirtualAce in forum Tech Board
    Replies: 2
    Last Post: 08-04-2003, 10:56 AM
  3. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM
  4. Replies: 1
    Last Post: 12-01-2001, 08:17 AM
  5. bug for static functions in template class
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2001, 06:38 PM