什么是列表:zf/2 (Erlang)?
What is lists:zf/2 (Erlang)?
为什么 lists:zf/2 在 Erlang 中是 filtermap/2 的别名?
这是列表中一个未记录但已导出的函数:模块。这是实现:
zf(F, L) ->
filtermap(F, L).
让我莫名其妙的是:
- 它有什么用?
- “zf”代表什么? “策梅洛-弗兰克尔”?
作为 Erlang 的共同发明人罗伯特·维尔丁,wrote in 2016:
The lists:zf/2 function came before list comprehensions and is a combination of map and filter. Like describing a set from a set of rules. Hence the Zermelo-Fraenkel based name. It is also called lists:filtermap/2 but where’s the fun in that?
所以,你的猜测完全正确。
我的旧答案完全正确,它确实代表 Zermelo-Fraenkel。这个名字被选为一个笑话。那时我们可以做到。
这类似于为什么我们在进程信息中使用 'reductions' 来衡量进程完成了多少工作,基本上是函数调用的次数。最初,很久以前,Erlang 是在 Prolog 中实现的,那里有缩减而不是函数调用,我们决定把它作为一个笑话。任何关于它与功能语言理论有关的建议都是错误的。
为什么 lists:zf/2 在 Erlang 中是 filtermap/2 的别名?
这是列表中一个未记录但已导出的函数:模块。这是实现:
zf(F, L) ->
filtermap(F, L).
让我莫名其妙的是:
- 它有什么用?
- “zf”代表什么? “策梅洛-弗兰克尔”?
作为 Erlang 的共同发明人罗伯特·维尔丁,wrote in 2016:
The lists:zf/2 function came before list comprehensions and is a combination of map and filter. Like describing a set from a set of rules. Hence the Zermelo-Fraenkel based name. It is also called lists:filtermap/2 but where’s the fun in that?
所以,你的猜测完全正确。
我的旧答案完全正确,它确实代表 Zermelo-Fraenkel。这个名字被选为一个笑话。那时我们可以做到。
这类似于为什么我们在进程信息中使用 'reductions' 来衡量进程完成了多少工作,基本上是函数调用的次数。最初,很久以前,Erlang 是在 Prolog 中实现的,那里有缩减而不是函数调用,我们决定把它作为一个笑话。任何关于它与功能语言理论有关的建议都是错误的。