文章摘要
这篇文章介绍了TinyAPL编程语言中的组合器(Combinators)概念,它是该语言的核心功能之一。组合器允许将函数以特定方式组合使用,类似于函数式编程中的高阶函数。文章属于TinyAPL文档的一部分,提供了关于组合器的详细说明,并列出了相关的其他文档链接。
文章总结
TinyAPL 组合子文档
概述
本文档介绍了TinyAPL编程语言中的组合子(Combinators)功能。组合子是指仅引用其参数和操作数而不以任何方式修改它们的函数或运算符。
组合子对照表
| 符号 | APL表达式 | 鸟类名称(参考) | TinyAPL实现 | 示意图 |
|------|-----------|---------------|-------------|--------|
| I | y | 恒等(Identity) | ⊣/⊢ | |
| K |
x | 红隼(Kestrel) | ⊣ | |
| κ |
y | 风筝(Kite) | ⊢ | |
| W |
y F y | 莺(Warbler) | ⍨ | |
| C |
y F x | 红衣主教(Cardinal) | ⍨ | |
| B |
F (G y) | 蓝鸟(Bluebird) | ∘/⍤/⍥ | |
| Q |
G (F y) | 怪鸟(Queer) | ⍛ | |
| B₁ |
F (x G y) | 黑鸟(Blackbird) | ⍤ | |
| Ψ |
(G x) F (G y) | Psi | ⍥ | |
| S |
y F (G y) | 椋鸟(Starling) | ⟜/⇽ | |
| Σ |
(F y) G y | 紫椋鸟(Violet Starling) | ⊸/⇾ | |
| D |
x F (G y) | 鸽子(Dove) | ∘/⟜ | |
| Δ |
(F x) G y | 斑鸠(Zebra Dove) | ⍛/⊸ | |
| Φ |
(F y) G (H y) | 凤凰(Phoenix) | «» | |
| Φ₁ |
(x F y) G (x H y) | 雉鸡(Pheasant) | «» | |
| D₂ |
(F x) G (H y) | 小海雀(Dovekie) | ⊸+⟜ | |
| P |
(y G x) F (x G y) | 鹦鹉(Parrot) | ⸚ | |
| N |
x F (x G y) | 东方尼卡雀(Eastern Nicator) | ⇽ | |
| ν |
(x F y) G y | 西方尼卡雀(Western Nicator) | ⇾ | |
其他组合子式操作
| APL表达式 | TinyAPL实现 | 示意图 |
|-----------|-------------|--------|
| n | ⍨ | |
|
n | ⍨ | |
|
F y | ⁖ | |
|
x G y | ⁖ | |
注释
- 部分组合子的鸟类名称来源于Raymond Smullyan的《To Mock a Mockingbird》一书,部分名称参考了Uiua组合子文档。
- 鹦鹉(Parrot)这个名称是作者自创的。
注:本文档省略了原始内容中的导航菜单和符号索引部分,专注于组合子的核心说明。
评论总结
这篇评论总结围绕三个主要观点展开:
- 对Y组合子及相关概念的讨论
- 正面评价:"The y-combinator is widely regarded as the best combinator :)"(hrmtst93837)
- 学术关联:"There is a deep and lovely connection between the Y-combinator and...Godel's incompleteness theorem"(gregfjohnson)
- 对编程语言发展的批评
- 批评现状:"we're still stuck at that same level of infantilism...reinventing the wheel every 5 minutes"(rdevilla)
- 建议改进:"I wish universal and eternal patterns like this were studied more often"(rdevilla)
- 技术细节探讨
- 语言实现问题:"how much array-oriented languages...would benefit from being implemented on top of an interaction net machine?"(ux266478)
- 类型系统疑问:"Is there a typed variant of logical combinators?"(pklausler)
其他次要观点包括对新读者缺乏背景说明的关注(siruwastaken)以及对APL语言特定功能的期待(cat-whisperer)。