gpt4 book ai didi

programming-languages - 什么是 "Total Functional Programming"?

转载 作者:行者123 更新时间:2023-12-03 13:18:37 26 4
gpt4 key购买 nike

Wikipedia有话要说:

Total functional programming (also known as strong functional programming, to be contrasted with ordinary, or weak functional programming) is a programming paradigm which restricts the range of programs to those which are provably terminating.





These restrictions mean that total functional programming is not Turing-complete. However, the set of algorithms which can be used is still huge. For example, any algorithm which has had an asymptotic upper bound calculated for it can be trivially transformed into a provably-terminating function by using the upper bound as an extra argument which is decremented upon each iteration or recursion.



还有一篇关于 Total Functional Programming 上的论文的 Lambda The Ultimate Post .

直到上周,我才在邮件列表中发现了这一点。

是否有更多您知道的资源、引用资料或任何示例实现?

最佳答案

如果我理解正确的话,Total Functional Programming 的意思就是:使用 Total Functions 进行编程。如果我没记错我的数学类(class),总函数是在其整个域中定义的函数,部分函数是在其定义中有“漏洞”的函数。

现在,如果你有一个函数可以用于某些输入值 v进入无限递归或无限循环,或者通常不会以其他方式终止,那么您的函数未定义为 v ,因此是部分的,即不是全部的。

Total Functional Programming 不允许您编写这样的函数。所有函数总是为所有可能的输入返回一个结果;并且类型检查器确保是这种情况。

我的猜测是,这极大地简化了错误处理:没有。

您的报价中已经提到了缺点:它不是图灵完备的。例如。操作系统本质上是一个巨大的无限循环。事实上,我们不希望操作系统终止,我们称这种行为为“崩溃”,并为此对我们的计算机大喊大叫!

关于programming-languages - 什么是 "Total Functional Programming"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/145263/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com