随笔分类 -  Javascript

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 30 下一页
摘要:What is Arrow Functor? Arrow is a Profunctor that lifts a function of type a -> b and allows for lazy execution of the function. Arrow can be consider 阅读全文
posted @ 2019-03-21 00:22 Zhentiw 阅读(342) 评论(0) 推荐(0)
摘要:Let's we have some prediction functions, for each prediction function has a corresponding tag: So if we have input as: Also we wish our program to the 阅读全文
posted @ 2019-03-19 21:11 Zhentiw 阅读(276) 评论(0) 推荐(0)
摘要:What we are going to do in this post, is to build a random number generator. As you might know that Javascript provides Math.random(), but the problem 阅读全文
posted @ 2019-03-16 20:07 Zhentiw 阅读(221) 评论(0) 推荐(0)
摘要:Implement a job scheduler which takes in a function f and an integer n, and calls f after nmilliseconds 阅读全文
posted @ 2019-03-13 06:05 Zhentiw 阅读(245) 评论(0) 推荐(0)
摘要:The act of currying can be described as taking a multivariate function and turning it into a series of unary functions. Let's see an example: This is 阅读全文
posted @ 2019-03-12 00:08 Zhentiw 阅读(159) 评论(0) 推荐(0)
摘要:This post is similar to previous post. The difference is in this post, we are going to see how to handle both successfuly result and error result by u 阅读全文
posted @ 2019-03-10 21:17 Zhentiw 阅读(193) 评论(0) 推荐(0)
摘要:Let's say we are going to read some files, return the first file which pass the prediction method, this prediction method can be just check whether th 阅读全文
posted @ 2019-03-10 04:24 Zhentiw 阅读(247) 评论(0) 推荐(0)
摘要:/**@abstract * Write your own Math.pow(a int, b int) function * */ function pow (a, b) { let result = 0; let nigate = b = 2) { result = isEven ? pow(a, b / 2) * pow(a, b / 2) : a * pow(... 阅读全文
posted @ 2019-03-08 19:06 Zhentiw 阅读(192) 评论(0) 推荐(0)
摘要:cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and 阅读全文
posted @ 2019-03-08 18:16 Zhentiw 阅读(302) 评论(0) 推荐(0)
摘要:You probably have functions that aren’t equipped to accept a Maybe as an argument. And in most cases, altering functions to accept a specific containe 阅读全文
posted @ 2019-03-05 17:28 Zhentiw 阅读(252) 评论(0) 推荐(0)
摘要:We can dot-chain our way to great success with an instance of Maybe, but there are probably cases where you need to apply the same series of transform 阅读全文
posted @ 2019-03-05 17:15 Zhentiw 阅读(431) 评论(0) 推荐(0)
摘要:We've seen how we can transduce from arrays or other iterables, but plain objects aren't iterable in Javascript. In this lesson we'll modify our trans 阅读全文
posted @ 2019-03-04 20:57 Zhentiw 阅读(282) 评论(0) 推荐(0)
摘要:We see three varied examples of where natural transformations come in handy. Let's mark the law here for Natural Transformations: Then let's see why w 阅读全文
posted @ 2019-03-01 22:24 Zhentiw 阅读(281) 评论(0) 推荐(0)
摘要:Natural Transformations, let's explain it by using a coding example, for example, we have a 'Either' holding a value 'a' and we want to transform a' T 阅读全文
posted @ 2019-03-01 21:30 Zhentiw 阅读(265) 评论(0) 推荐(0)
摘要:We use the traversable instance on List to reimplement Promise.all() type functionality. For example we want to conver: Conver array of Task, into Tas 阅读全文
posted @ 2019-03-01 14:31 Zhentiw 阅读(272) 评论(0) 推荐(0)
摘要:We annihilate the need for the ol' nested for loop using Applicatives. For example we have this kind of nested loop code: We can refactor it by using 阅读全文
posted @ 2019-02-28 20:53 Zhentiw 阅读(174) 评论(0) 推荐(0)
摘要:Working our way backwards from solution to problem, we define an applicative functor, then use it to apply a function of multiple arguments. For examp 阅读全文
posted @ 2019-02-28 19:02 Zhentiw 阅读(205) 评论(0) 推荐(0)
摘要:We refactor a standard node callback style workflow into a composed task-based workflow. Original Code: Using Task: Using Async: 阅读全文
posted @ 2019-02-27 16:05 Zhentiw 阅读(235) 评论(0) 推荐(0)
摘要:Let's examine a pointfree way to write these applicative calls. Since we know map is equal to of/ap, we can write generic functions that will ap as ma 阅读全文
posted @ 2019-02-27 03:09 Zhentiw 阅读(179) 评论(0) 推荐(0)
摘要:We examine the data structure Task, see some constructors, familiar methods, and finally how it captures side effects through laziness. We are going t 阅读全文
posted @ 2019-02-26 18:34 Zhentiw 阅读(252) 评论(0) 推荐(0)

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 30 下一页