为什么程序员应该关心 Monoids?因为 Monoids 是一种在编程中反复出现的常见模式。当模式出现时,我们可以将它们抽象化并利用我们过去所做的工作。这使我们能够在经过验证的稳定代码之上快速开发解决方案。
将"可交换性"添加到 Monoid(Commutative Monoid),你就有了可以并行执行的东西。随着摩尔定律的终结,并行计算是我们提高处理速度的唯一希望。
以下是我在学习 Monoids 后学到的。它未必完整,但希望能够对于向人们介绍 Monoids 有所帮助。
{% comment %} | |
* | |
* This loop loops through a collection called `collection_name` | |
* and sorts it by the front matter variable `date` and than filters | |
* the collection with `reverse` in reverse order | |
* | |
* To make it work you first have to assign the data to a new string | |
* called `sorted`. | |
* | |
{% endcomment %} |