TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How to Average in Prolog (2017)

72 点作者 todsacerdoti3 天前

5 条评论

fuzz_junket2 天前
The author seems to be frustrated at something but I&#x27;m not sure what. There is value in learning how to implement something from first principles. Teachers aren&#x27;t sitting around scheming about how they can waste their students&#x27; time with &quot;meaningless calisthenics&quot;, they&#x27;re trying to help them. Calling them &quot;clueless professors&quot; isn&#x27;t great either. There&#x27;s a degree of disrespect in undergraduates dunking on professional tertiary-level educators for making them do homework.<p>Also, Prolog does not have a &quot;standard library&quot;. 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.
danilafe3 天前
This is a strange article to me. I&#x27;ve not seen any class that teaches Prolog place these constraints (use recursion &#x2F; don&#x27;t add new predicates) or even accidentally have the outcome of &quot;making prolog look tedious&quot;. What&#x27;s the joke here?<p>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&#x27;d be curious if anyone knows otherwise.
评论 #43920919 未加载
评论 #43920552 未加载
评论 #43922117 未加载
评论 #43920901 未加载
Pinus2 天前
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 <i>feel</i> 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.<p>Admittedly, teachers sometimes seem to lose track of this and assign busywork exercises for no good reason.
pjmlp2 天前
Love the jab regarding &quot;only tools available in the 18th century&quot;, applies to so many things in mainstream computing.
timonoko2 天前
TIL: Grok cannot do Prolog, it insists that<p><pre><code> average([X],X) :- !. </code></pre> is better than<p><pre><code> average([X],X).</code></pre>