更改

跳到导航 跳到搜索
添加862字节 、 2021年7月7日 (三) 23:39
建立内容为“Category:Haskell Haskell 是一种函数式编程语言。 == 笔记 == === <code>let</code> 与 <code>where</code> === <code>let</code> 是一个表达式…”的新页面
[[Category:Haskell]]
Haskell 是一种函数式编程语言。

== 笔记 ==

=== <code>let</code> 与 <code>where</code> ===

<code>let</code> 是一个表达式,而 <code>where</code> 不是。<code>where</code> 用于给多个 guard 创建 binding,如下:
<syntaxhighlight lang=haskell>
f x y
| y > z = ...
| y == z = ...
| y < z = ...
where
z = x * x
</syntaxhighlight>
三个 guard 都可使用 <code>z</code>。用 <code>let</code> 无法达到以上的效果。<ref>https://stackoverflow.com/q/4362328/10974106</ref><ref>[https://www.cse.iitb.ac.in/~as/fpcourse/haskell98_tutorial/patterns.html A Gentle Introduction to Haskell] 4.5 Lexical Scoping and Nested Forms</ref>

== 外部链接 ==

* [https://www.haskell.org/ 主页]
* [http://cheatsheet.codeslower.com/CheatSheet.pdf Haskell CheetSheet]

== 参考资料 ==

<references />

导航菜单