“foop”:命名惯例?它是“foo”的帮助递归函数;后缀“p”是什么?意思? [英] "foop": a naming convention? It's a helper recursive function for "foo"; what does the suffix "p" mean?
问题描述
我遇到了下面的代码片断(一个函数定义):
choose(x: xs)= choosep x xs
where choosep x [] = x
choosep x(_:_)= x
choosep _(x:xs)= choosep x xs
in 库里编程语言在标准库中 - / usr / lib / curry-0.9.11 / Success.curry from 明斯特咖喱编译器。这里:
choose :: [a] - > a
和
choosep :: a - > [a] - > a - 顺便说一句,不是_p_redicate
是p后缀对于helper递归函数 choosep
一个已知的命名约定?也许它来自函数式编程的传统(Haskell)或逻辑编程(Prolog?)。这是什么意思?
(这个函数在为什么是在Curry的std库中的非确定性选择函数没有直接定义,而是用一个辅助函数2参数函数?。)
我认为它代表'prime' - 在OCaml中,它允许在标识符中使用'
,帮助函数通常被命名为 foo'
。在很高的层面上,我认为这一点(以及使用where来表示事后助手定义)源于希望允许功能程序类似于纯数学中的等价定义。
I've come across the following code snippet (a function definition):
choose (x:xs) = choosep x xs
where choosep x [] = x
choosep x (_:_) = x
choosep _ (x:xs) = choosep x xs
in Curry programming language in a "standard library"--/usr/lib/curry-0.9.11/Success.curry from Muenster Curry Compiler. Here:
choose :: [a] -> a
and
choosep :: a -> [a] -> a -- BTW, not a _p_redicate
Is the "p" suffix for the helper recursive function choosep
a known naming convention? Perhaps it comes from functional programming tradition (Haskell) or logical programming (Prolog?). What does it mean then?
(This function was considered in Why is the non-deterministic choice function in Curry's std lib not defined straightforwardly but rather with a helper 2-argument function?.)
I think it stands for 'prime' -- in OCaml, which allows '
in identifiers, helper functions are frequently named foo'
. At a high level, I think this (and the use of 'where' for a post-hoc helper definition) stems from the desire to allow functional programs to resemble their equivalent definitions in pure math.
这篇关于“foop”:命名惯例?它是“foo”的帮助递归函数;后缀“p”是什么?意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!