How to Average in Prolog (2017)

storytotell.org

71 points by todsacerdoti 2 days ago


fuzz_junket - 2 days ago

The author seems to be frustrated at something but I'm not sure what. There is value in learning how to implement something from first principles. Teachers aren't sitting around scheming about how they can waste their students' time with "meaningless calisthenics", they're trying to help them. Calling them "clueless professors" isn't great either. There's a degree of disrespect in undergraduates dunking on professional tertiary-level educators for making them do homework.

Also, Prolog does not have a "standard library". What predicates are implemented varies greatly by implementation, and if you want to write portable code then you have to stick as closely as possible to the ISO standard.

danilafe - 2 days ago

This is a strange article to me. I've not seen any class that teaches Prolog place these constraints (use recursion / don't add new predicates) or even accidentally have the outcome of "making prolog look tedious". What's the joke here?

That aside, I wonder if getting the reverse solution (sum(?, 10)) is better served by the straightforward or the tedious approach. I suspect both would work just the same, but I'd be curious if anyone knows otherwise.

Pinus - 2 days ago

It’s been more than 30 years since I took a (very basic) course in logic programming in general and Prolog in particular, so I can’t read the level of sarcasm in the text, but: Surely, when a course places various artificial limitations on programming, like “hands off the standard library”, the reason is that they are not trying to teach you to be productive Prolog (or whatever language) programmers, they are trying to teach you basic principles, and truly internalizing those principles often (not for everyone!) requires swimming around in them for a while. In Lisp, you are not just supposed to know that you can write a tail-recursive function for something, you are supposed to have done it so many times that you can do it almost without thinking. In calculus, you are not supposed to look up the derivative of arcsin in a table, you are supposed to feel it, so that to immediately see that that subsituting t=sin(x) makes that integral much nicer. They are not training you to use the standard library, they are training you to write it.

Admittedly, teachers sometimes seem to lose track of this and assign busywork exercises for no good reason.

pjmlp - 2 days ago

Love the jab regarding "only tools available in the 18th century", applies to so many things in mainstream computing.

timonoko - a day ago

TIL: Grok cannot do Prolog, it insists that

  average([X],X) :- !.
is better than

  average([X],X).
me3meme - 2 days ago

[flagged]