Hacker News 中文摘要

RSS订阅

组合子 -- Combinators

文章摘要

这篇文章介绍了TinyAPL编程语言中的组合器(Combinators)概念,它是该语言的核心功能之一。组合器允许将函数以特定方式组合使用,类似于函数式编程中的高阶函数。文章属于TinyAPL文档的一部分,提供了关于组合器的详细说明,并列出了相关的其他文档链接。

文章总结

TinyAPL 组合子文档

概述

本文档介绍了TinyAPL编程语言中的组合子(Combinators)功能。组合子是指仅引用其参数和操作数而不以任何方式修改它们的函数或运算符。

组合子对照表

| 符号 | APL表达式 | 鸟类名称(参考) | TinyAPL实现 | 示意图 | |------|-----------|---------------|-------------|--------| | I | y | 恒等(Identity) | / | Same | | K | x | 红隼(Kestrel) | | Left | | κ | y | 风筝(Kite) | | Right | | W | y F y | 莺(Warbler) | | Duplicate | | C | y F x | 红衣主教(Cardinal) | | Commute | | B | F (G y) | 蓝鸟(Bluebird) | // | Compose | | Q | G (F y) | 怪鸟(Queer) | | Reverse Compose | | B₁ | F (x G y) | 黑鸟(Blackbird) | | Atop | | Ψ | (G x) F (G y) | Psi | | Over | | S | y F (G y) | 椋鸟(Starling) | / | Right Hook | | Σ | (F y) G y | 紫椋鸟(Violet Starling) | / | Left Hook | | D | x F (G y) | 鸽子(Dove) | / | After | | Δ | (F x) G y | 斑鸠(Zebra Dove) | / | Before | | Φ | (F y) G (H y) | 凤凰(Phoenix) | «» | Fork(monad) | | Φ₁ | (x F y) G (x H y) | 雉鸡(Pheasant) | «» | Fork(dyad) | | D₂ | (F x) G (H y) | 小海雀(Dovekie) | + | Bracket | | P | (y G x) F (x G y) | 鹦鹉(Parrot) | | Mirror | | N | x F (x G y) | 东方尼卡雀(Eastern Nicator) | | Right Fork | | ν | (x F y) G y | 西方尼卡雀(Western Nicator) | | Left Fork |

其他组合子式操作

| APL表达式 | TinyAPL实现 | 示意图 | |-----------|-------------|--------| | n | | Constant(monad) | | n | | Constant(dyad) | | F y | | Valences(monad) | | x G y | | Valences(dyad) |

注释

  1. 部分组合子的鸟类名称来源于Raymond Smullyan的《To Mock a Mockingbird》一书,部分名称参考了Uiua组合子文档。
  2. 鹦鹉(Parrot)这个名称是作者自创的。

注:本文档省略了原始内容中的导航菜单和符号索引部分,专注于组合子的核心说明。

评论总结

这篇评论总结围绕三个主要观点展开:

  1. 对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)
  1. 对编程语言发展的批评
  • 批评现状:"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)
  1. 技术细节探讨
  • 语言实现问题:"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)。