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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Translating mathematics into code

150 点作者 edsrzf超过 13 年前

4 条评论

ScottBurson超过 13 年前
Nice to see this.<p>I'm convinced, from long experience, from long experience, that functional collections are stylistically superior to imperative collections, even in otherwise imperative code.<p>In fact I'd go so far as to say that the worst mistake van Rossum made in designing Python was not to use functional collections. Then we wouldn't need to discuss how to copy them: <a href="http://news.ycombinator.com/item?id=3201033" rel="nofollow">http://news.ycombinator.com/item?id=3201033</a> There also wouldn't be this bug where using an empty list as the default value of an optional parameter would do the wrong thing (the same list object is reused on subsequent calls, when it is no longer empty).<p>(Yes, I understand, Python does have functional sets, but not AFAICT functional sequences or maps.)<p>It's great to see that Rich Hickey has designed Clojure around functional collections. I'm sure he'll do more for the cause than my own FSet library for Common Lisp, but I'll plug the latter anyway: <a href="http://common-lisp.net/project/fset/" rel="nofollow">http://common-lisp.net/project/fset/</a>
评论 #3234275 未加载
评论 #3232907 未加载
评论 #3233544 未加载
bane超过 13 年前
Okay, 94 points and still no comments, I'll bite.<p>I think the difference here is, and I don't think this is a subject that has been thought about quite enough, is that mathematics typically describe <i>calculation</i>, while code describes a superset of calculation, <i>computation</i>.<p>When we spend all our time working with the more expansive set, computation, we sometimes forget that calculation is in many ways less expressive and has fewer ways to express a thing. Many of the ideas in the article seem to be about getting over things we take for granted in computation, and understanding how to operate in the more limited framework offered by calculation, and/or understanding that even if things look kind of alike (what's a good word for this concept? a homoscript?) in computation vs. calculation they can be subtly different with a range of pitfalls.
评论 #3232790 未加载
评论 #3235399 未加载
评论 #3233525 未加载
dvanduzer超过 13 年前
"Math has no side effects" might be the most concise explanation of every computer science problem since 1970.
dubya超过 13 年前
"Pearls of functional algorithm design" by Richard Bird is a fabulous book along these lines. It's not exactly light reading, but the chapters are short, and some of the results are surprising, like the faster implementation of nub (unique elements in a list).<p>An aside: I was trying to brush up on Python and looked at Learn Python the Hard Way, and found exercise 25 absolutely appalling. I hope that's not idiomatic Python.