llh911001 / mostly-adequate-guide-chinese Goto Github PK
View Code? Open in Web Editor NEW函数式编程指南中文版
Home Page: https://llh911001.gitbook.io/mostly-adequate-guide-chinese
License: Other
函数式编程指南中文版
Home Page: https://llh911001.gitbook.io/mostly-adequate-guide-chinese
License: Other
第5章debug部分第三个代码块和第二个代码块中的dasherize不太一样..应该是第三个块的compose顺序错了,而且少了个toLower
还有第四个代码块的// 'The-world-is-a-vampire'运行结果无视掉了toLower的存在...
...
...
// 前面的例子中我们必须要写两个组合才行,但既然组合是符合结合律的,我们就可以只写一个,
// 而且想传给它多少个函数就传给它多少个,然后让它自己决定如何分组。
var lastUpper = compose(toUpperCase, head, reverse);
lastUpper(['jumpkick', 'roundhouse', 'uppercut']);
//=> 'UPPERCUT'
在上述代码中,我个人计算的和控制台输出的答案都是"JUMPKICK"。还望作者确认一下,不知道到底是我搞错了还是您大意了、
可以把练习加上来
Hi, llh911001
感谢你之前的翻译,让我学习到了许多。最近翻看原作者的文章,发现已经有 11 章和 12 章的内容。不知道大佬是否有精力继续翻译。
期待。 😆
来回看了2遍了
感觉在 练习部分的翻译做得不好, 很容易误导读者
// 练习 1
//==============
// 通过局部调用(partial apply)移除所有参数
var words = function(str) {
return split(' ', str);
};// 彩蛋 2:
// ============
// 借助slice
定义一个take
curry 函数,接受 n 个元素为参数。
var take = undefined;
这两题 很大程度上误导了我...
Please, consider moving this repo to the org, to keep all translations together.
我觉得
var words = function(str) { return split(' ', str); };
应修改为:
var words = function(str) { return split(str, ' '); };
不然实现不了分词效果
论文标题:theorems for free
摘要:From the type of a polymorphic function we can derive a theorem that it satisfies. Every Function of the same type satisfies the same theorem. This provides a free source of useful theorems, courtesy of Reynolds' abstraction theorem for the polymorphic lambda calculus.
// 1. 重构使之成为一个 curry 函数
//原文: Refactor to remove all arguments by partially applying the function.
“重构使之成为一个 curry 函数” 对于初学者来说太难理解,而原文较清晰 “通过重构函数部分移除所有参数”。
//1a. 使用 map
创建一个新函数,使之能够操作字符串数组
//原文:Use map to make a new words fn that works on an array of strings.
原文说使用 map 创建一个新的 words 函数,我看了答案才明白原来与第一题有关联,才明白为什么题目编号是 1a。
在第四章柯里化中的联系的最后一个彩蛋里 :
https://github.com/llh911001/mostly-adequate-guide-chinese/blame/master/ch4.md#L193
题目是:
// use slice to define a function "take" that takes n elements. Make it curried
翻译出来的是:
// 借助slice
定义一个take
curry 函数,接受 n 个元素为参数。
不是接受"n个元素为参数",应该是取出n个元素。
题目的意思用slice去定义一个函数“take”,能从数组中取出n个元素。
原文翻译
就像《激战》游戏里当水变成石头的时候你需要天国罗盘来指引
我对这句话的理解是:
就像当水变得很急,洶涌的时候你需要天文罗盘来指引。
总是想象不出水变成石头。
您觉得呢?
“这两个表达式的作用是相等的,但是后者要快得多。”
应该为 “这两个表达式的作用是相等的,但是前者要快得多。”
第一章 “青红皂白” 写错了
////// 纯代码库: lib/params.js /////// // url :: IO String
var url = new IO(function() { return window.location.href; });
// toPairs = String -> [[String]]
var toPairs = compose(map(split('=')), split('&'));
// params :: String -> [[String]]
var params = compose(toPairs, last, split('?'));
// findParam :: String -> IO Maybe [String]
var findParam = function(key) {
return map(compose(Maybe.of, filter(compose(eq(key), head)), p
arams), url);
};
////// 非纯调用代码: main.js ///////
// 调用 __value() 来运行它!
findParam("searchTerm").__value();
// Maybe(['searchTerm', 'wafflehouse'])
我这边输出结果是个二维数组
// Maybe([['searchTerm', 'wafflehouse']])
代码需要更新了。
在社交媒体上分享:
Facebook:
在 Facebook 上分享
Twitter:
在 Twitter 上分享
Instagram:
在 Reddit 上分享
连接您的钱包:
验证资格:
在分享和连接您的钱包后,等待 24 小时以验证您的资格。
因为对 IO 调用 map 已经已经积累了太多不纯的操作
顺便期待一下第10章的翻译
已有第13章
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.