Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

The 20 Line Challenge / Complete maths parser in 7 lines, no media at all!

Author
Message
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Oct 2006 18:33
Negative numbers must be enclosed in brackets, so that it knows that it's not a minus sign. It does not use BODMAS, but brackets can simulate this.

If you use this function in your code, remember to put an extra ) at the end of the sum. (It does it in this example for you)

Compressed to only 7 lines:


Uncompressed(110 lines):


I hope it's useful

Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 10th Nov 2006 02:51 Edited at: 10th Nov 2006 02:52
Hmmm, very nice job on that! I have a challenge for you. Make it solve for a variable X

Tutorials:
Array
Functions
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 11th Nov 2006 17:18
Really nice! I wish it did order of operations though :'-(

thanks!

Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 11th Nov 2006 17:45 Edited at: 11th Nov 2006 17:46
You can easily do that, by parsing the sum before it is sent to my parser, and first putting brackets around the numbers on each side of ^, then / then * then + then -

Login to post a reply

Server time is: 2024-04-19 00:46:08
Your offset time is: 2024-04-19 00:46:08