A Expression Calculator using Linked Lists!

It’s the longest C project I’ve written to date. I used linked lists in order to make it fast, one node of the list represents a number and its properties and the operator affecting it. Branches are introduced to mimic brackets. The user will give a normal string input like “1+2” and the output will be 3. But what they don’t see is the implementation. The list will include two nodes for 1 and 2 and with their operators(both + in this case). Then the calculation function will go through this list.

When there are brackets, for example : 1+(1+5)/6 the two lists will be made and one will have +1,+5 and it’ll be linked at theĀ appropriate location on the main list which will be like 1+[link_to_list_1]/6 since the calculation is done recursively, when the function reaches the end of the main list other child lists’ values will be assigned and then simplified.

It includes the following preset functions(it only supports one argument functions up to now),

sin, cos, tan, asin, acos, atan. dtor, rtod, fact

Download the source and Linux executable