3 ms·
With logic languages it goes from wrong, wrong, wrong, x100 ..., aha I got it and it is beautiful and short. In my experience, it only works like that when you
by danieldk 13y ago
With logic languages it goes from wrong, wrong, wrong, x100 ..., aha I got it and it is beautiful and short.
In my experience, it only works like that when you are fairly new in the language. Later it works like most other languages: build small and understandable predicates. Compose and refine.
Another reason that it's usually easy to move to a working version in Prolog quickly is that the tracing capabilities in most implementations are excellent. So, it's really simple to see if a predicate works as you expected to, since you can walk through a proof step by step.
What's harder in Prolog is that it is relatively easy to mess up predicates such that they are not 'steadfast'. In the words of the inventor of this term: "Steadfastness basically means that you cannot force a predicate down the wrong path by filling in output arguments wrongly."[1]
[1] http://blog.gmane.org/gmane.comp.ai.prolog.swi/month=20090301 http://blog.gmane.org/gmane.comp.ai.prolog.swi/month=2009030...
- rdtsc 13y ago> "Steadfastness basically means that you cannot force a predicate down the wrong path by filling in output arguments wrongly."[1] Interesting. Yeah is how I often mess up. The backtracking just ends up going the wrong way. Are you familiar with Mercury, what do you think of it. They add besides type, also predicate determinism. Something like (copy paste from its example code): > :- mode append(in, in, out) is det. :- mode append(out, out, in) is multi. Here they determine various determinism modes of predicate append. Do you see that as a good improvement? Very useful? Or a nice to have option?
- danieldk 13y agoUnfortunately, I have never used Mercury. But it likes like a nice addition to be able to specify in/out arguments. In Prolog there are the ?/-/+ markings, but these are for documentary purposes.