13,000,469 members (57,793 online)
Rate this:
See more: (untagged)
i wanna make calculator using prologe any help guys please any tutorials ?
Posted 27-Apr-12 8:56am
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.

Rate this:

## Solution 1

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

Cheers,

Manfred
SAKryukov 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
Rate this:

## Solution 2

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/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
v2
Manfred R. Bihy 27-Apr-12 15:49pm

Well argumented, SA! 5+
SAKryukov 27-Apr-12 15:51pm

I tried hard. :-)
Thank you, Manfred.
--SA

Top Experts
Last 24hrsThis month
 OriginalGriff 60 RickZeeland 53 Michael_Davies 50 ppolymorphe 45 Richard Deeming 40
 OriginalGriff 4,607 ppolymorphe 2,337 RickZeeland 2,211 Kornfeld Eliyahu Peter 1,993 Richard Deeming 1,633