3 ms·
That looks nice. List comprehensions, higher-order functions and arrays in a logic-based language with CLP and planning facilities sounds great. In terms of loo
by YeGoblynQueenne 9y ago
That looks nice. List comprehensions, higher-order functions and arrays in a logic-based language with CLP and planning facilities sounds great. In terms of looks, I'm not sure why but it reminds me of a cross between Python and Prolog.
There's a few things that look a bit strange though. e.g.:
perms([]) = [[]].
perms(Lst) = [[E|P] : E in Lst, P in perms(Lst.delete(E))].
So, "|" is a cons operator, but can't be used to take a list apart by recursively separating its head from its tail? That's a bit strange.
Also:
Compared with Prolog, Picat is arguably more expressive and
scalable: it is not rare to find problems for which Picat
requires an order of magnitude fewer lines of code to
describe than Prolog and Picat can be significantly faster
than Prolog because pattern-matching facilitates indexing of
rules.
That's just ... no :) [Because modern Prologs index all predicats, including rules, by pattern mathing and there's nothing more expressive than FOL so].
- ScottBurson 9y agoI don't know exactly what's meant by "pattern-matching facilitates indexing of rules", but I wouldn't dismiss it so quickly. Zhou has long experience with a Prolog implementation (B-Prolog) and seems to know his stuff. The tabling feature in particular suggests that this is a state-of-the-art offering. As for expressiveness, I think he's using the term in the sense of "how easy it is to express things", not "what is possible to express".
- YeGoblynQueenne 9y ago>> I don't know exactly what's meant by "pattern-matching facilitates indexing of rules", but I wouldn't dismiss it so quickly. Far as I can tell, "pattern-matching facilitates indexing of rules" means that the indexing scheme builds an index with a key for every instantiation pattern of a predicate in the program database. Prolog uses pattern matching to match a query (or a goal) to the head of a predicate in its database. To speed things up, predicates are indexed by their functor name (the predicate symbol) and the value of their first argument, if it is a constant. That's all for default Prolog. In modern Prologs keys are built for deeper patterns- more arguments, or compound arguments at different depth etc. The particulars depend on the implementation, but basically what I get from "pattern matching facilitates etc" is that Picat allows indexing on multiple arguments, including compound terms, which could enable matching the entire pattern of a query to an index key. Which is cool and all but it's not something you won't find in Prolog. You can find details of one indexing scheme for Prolog in Swi-Prolog's documentation on its jiti clause indexing, here: http://www.swi-prolog.org/pldoc/man?section=jitindex http://www.swi-prolog.org/pldoc/man?section=jitindex Hope the above makes sense- I assume some knowledge of Prolog, let me know otherwise and I'm happy to clarify.
- ScottBurson 9y agoAh, that's interesting. I wasn't aware that modern Prologs did that much indexing, though it stands to reason that they would; I hadn't really thought about it.
- naasking 9y agoTo second the other poster, (Felleisen) expressiveness is not power, it's more like a ratio of power to program length.
- YeGoblynQueenne 9y agoSure, but that's a bit arbitrary. So I feel free to pick at it :)
- naasking 9y agoNot quite arbitrary, it's mathematically defined via Kolmogorov complexity, the latter just happens to be uncomputable, so we only have approximations using the best available compression techniques. It's good enough for rough estimates.
- YeGoblynQueenne 9y agoIn principle, maybe. In practice people mean that they can write program P in language A in n lines, whereas they need m lines to write P in language B, therefore A is better than B because m > n. Which of course means nothing- I can probably write a hello world in 1000 lines in Java, if I try really hard. Just because I can find a shorter program in my favourite language but can't find one in yours, doesn't mean one doesn't exist. And even if you yourself can't find such a program, doesn't mean it doesn't exist. That's what I mean by "arbitrary": in practice, people come up with whatever interpretation of "expressive" suits them to claim their favourite language is more of that.
- naasking 9y ago> Just because I can find a shorter program in my favourite language but can't find one in yours, doesn't mean one doesn't exist. And even if you yourself can't find such a program, doesn't mean it doesn't exist. This doesn't matter. Ordering all program strings by Kolmogorov complexity means you can find the shortest program that can produce a certain output string.