Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: logic
i wanna make calculator using prologe any help guys please any tutorials ?
Posted 27-Apr-12 9:56am
Comments
wizardzz at 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: bad
good
Please Sign up or sign in to vote.

Solution 1

Googling "prolog calculator tutorial" got me this little gem: Prolog Calculator!
 
Cheers,
 
Manfred
  Permalink  
Comments
SAKryukov at 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: bad
good
Please Sign up or sign in to vote.

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/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
  Permalink  
v2
Comments
Manfred R. Bihy at 27-Apr-12 15:49pm
   
Well argumented, SA! 5+
SAKryukov at 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)

  Print Answers RSS
0 OriginalGriff 459
1 Maciej Los 325
2 Sergey Alexandrovich Kryukov 234
3 DamithSL 233
4 BillWoodruff 200
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 27 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100