- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
昨天我在 #145 的更新大佬好像没有看到,刚好今天上线又看到了 #237 的大佬提到的reduce的实现並,所以再更新一下,也用于抛砖引玉吧~~
「添一」 is predefined ahead, in JS might be:
function addOne(x) {
    return x+1;
}Impletements Array.prototype.map like:
吾有 「甲列」者,  皆「添一」其上,皆 「添一」其上,终得 「乙列」也
As for Array.prototype.reduce, just replace 皆 with 並
Javascript:
var bList = aList.map(addOne).map(addOne);In Addition, there's a possible implementation for compose:
吾有一数,名之曰 「添五」, 盖合「添一」, 「添一」, 「添一」, 「添一」,  「添一」者也
(The parser translate 吾有一术 to keyword function, so I use 吾有一数)
Javascript:
var addFive = compose(addOne, addOne, addOne, addOne, addOne)If functions in compose need params, can expand to:
吾有一数,名之曰 「添二」, 盖合「添」于「一」, 「添」于「一」者也
(But I forget whether the syntax is available in Traditional Chinese)
Of course, 「添」 and 「一」 might be:
function add(func) {
    return function(x) {
        return x + func();
    }
}
function one() {
    return 1;
}最后我想说,这样设计语法的目的也是为了写出短句,emmmm读起来更有节奏感吧🤣
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request