Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
i wanna make calculator using prologe any help guys please any tutorials ?
Posted
Comments
wizardzz 27-Apr-12 15:26pm    
You should pose a question when you get stuck on something specific, until then, well and even then, your friend is Google.

Googling "prolog calculator tutorial" got me this little gem: Prolog Calculator!

Cheers,

Manfred
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 27-Apr-12 15:38pm    
Wow! during the time I spend of explaining why all that makes no sense, you got a sample you call a little gem!
My 5, but nevertheless, in terms of general approach, I'm still holding my views: Prolog is no good for calculators, and a calculator is a poor way to learn Prolog -- please see.
--SA
I don't think you can find any good tutorial on this combination of topics, because I fail to imagine a reasonable knowledgeable person who would take this pointless task. Likewise, I would not advise you to waste your time on it.

If you want a good "regular" (numeric) calculator, Prolog would make little to no sense. This is a logic programming language, strongly declarative, with notoriously weak imperative semantics. Please see:
http://en.wikipedia.org/wiki/Prolog[^],
http://en.wikipedia.org/wiki/Logic_programming[^],
http://en.wikipedia.org/wiki/List_of_programming_languages_by_category#Declarative_languages[^],
http://en.wikipedia.org/wiki/Declarative_programming[^],
http://en.wikipedia.org/wiki/Imperative_programming[^].

Even if you use Prolog implementation with enforced (I would say, "artificially enforced") imperative feature, notably Object-Oriented Visual Prolog, formerly Borland Turbo Prolog, it would not match with several much more suitable languages. Please see:
http://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations[^],
http://en.wikipedia.org/wiki/Turbo_Prolog[^].

Generally, making a traditionally-looking calculator with buttons is a popular but very poor model for learning programming. Who need them? Anyone can easily make a decent expression-oriented calculator with any non-trivial scripting/interpretive language, because they have expression evaluators, which just few lines of code. For example, take a look at my JavaScript calculator:
http://sakryukov.org/freeware/calculator/[^].

Such calculators are possible just because the imperative interpretive languages can parse/evaluate strings containing expressions in the same language, like JavaScript Eval. Please see:
http://en.wikipedia.org/wiki/Interpretive_programming_language#Advantages_of_interpreting_a_language[^],
http://en.wikipedia.org/wiki/Interpreter_%28computing%29[^].

From the other hand, if I assume that you want to make a calculator to learn Prolog, I would advise to find a better goal. Such task would defeat the purpose of this language. In addition to having extra hassles, you would risk to go around essence of the logical programming and the essential features of the language.

And finally, I can assume that you are already knowledgeable in Prolog and want to polish your skills to make yourself a universal Prolog developer capable of solving nearly any problem. In this case, creation of the calculator could be justified, marginally, but in this case I would not advise to look for a tutorial. For such a developer, the regular detailed language reference could serve the best.



—SA
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 27-Apr-12 15:49pm    
Well argumented, SA! 5+
Sergey Alexandrovich Kryukov 27-Apr-12 15:51pm    
I tried hard. :-)
Thank you, Manfred.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900