gpt4 book ai didi

haskell - 运算符 % 在 Haskell 中是什么意思?

转载 作者:行者123 更新时间:2023-12-01 07:27:48 25 4
gpt4 key购买 nike

我想知道 Haskell 运算符 % 是做什么的。在谷歌上很难找到,我在 Haskell 报告中也找不到。

我在这段代码中看到它使用了它:

 fi=zz.bu
bu=zz.(:).(++"zz")
[]#zz=zz;zz#__=zz
zZ%zz=zZ zz$zZ%zz
zz=(([[],[]]++).)
zZ=zipWith;z=zZ((#).show)[1..]$zZ(++)(bu%"Fi")(fi%"Bu")

取自: https://codegolf.stackexchange.com/questions/88/obfuscated-fizzbuzz-golf/110#110

最佳答案

这是the relevant section haskell 报告的:

Haskell provides special syntax to support infix notation. An operator is a function that can be applied using infix syntax (Section 3.4), or partially applied using a section (Section 3.5).

An operator is either an operator symbol, such as + or $$, or is an ordinary identifier enclosed in grave accents (backquotes), such as `op`. For example, instead of writing the prefix application op x y, one can write the infix application x `op` y. If no fixity declaration is given for `op` then it defaults to highest precedence and left associativity (see Section 4.4.2).

Dually, an operator symbol can be converted to an ordinary identifier by enclosing it in parentheses. For example, (+) x y is equivalent to x + y, and foldr (*) 1 xs is equivalent to foldr (\x y -> x * y) 1 xs.


也就是说,Haskell 中的“操作符”除了语法没有什么特别之处。名称由符号组成的函数默认为中缀,名称为字母数字的函数默认为前缀,两者都可以通过一些额外的语法以另一种风格使用。
顺便说一句,由于通常无法使用 Google 根据运算符名称进行搜索,因此要查找标准库中声明的运算符,有两个 search engines专供 finding things关于黑客。

关于haskell - 运算符 % 在 Haskell 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14634363/

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