Results 1 to 3 of 3

Thread: Function Parser

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Question

    Has anyone ever written a function parser to do simple arithmetic? (obviously + - * / ^, maybe Sqr, log, ln, sin, cos, tan etc.)

    It would have to handle nested parentheses and recognise numbers as well as variables.

    (e.g. have a list of assignable variables like a-z, and then be able to type and evaluate a string such as:

    ((a+b)^c)*2.6 + 1

    )

    I've tried it before (in FORTRAN of all things) and its pretty hard....

    Just curious...


    Dan

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Location
    India
    Posts
    85

    Thumbs up

    I have done it in C
    It was really nice to work out that program.

    I wrote a program which will generate a Prefix an Postfix exression.

    Even I worked with another program which will find the number of executable lines in a C program.
    Here the input is a file with .c or .cpp extension and it will count the number of executable lines. here I have to find the '{' and also take into consideration the decalration statements.


    Even more interesting to me was generating a flowchar ( using c graphics) from a c program. When a .C file is given as input this application will generate the flowchar for that program. It really interesting to work with for loops and while loops and IF else conditions.....

    I am now working in VB but I still feel I love programming in C and C++ and as they are most creative

    Ramdas

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I've done one in vb, but it's slow
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width