Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第8章把野兽从笼子里放出来的例子 注释里的输出结果应该是个二维数组 #47

Open
GuoliangWang opened this issue Jul 13, 2019 · 0 comments

Comments

@GuoliangWang
Copy link

////// 纯代码库: 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']])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant