随笔分类 -  Javascript

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 31 下一页
摘要:Using Naive JS: The main problem is inside 'rando' function, not really a FP way doing stuff. Arrow approach: It becomes complex with we need to do Pa 阅读全文
posted @ 2019-03-26 17:15 Zhentiw 阅读(252) 评论(0) 推荐(0)
摘要:Recently, I am learning Working with ADT. Got some extra thought about State Monad. Basiclly how to thinking in State. First, we need to know the type 阅读全文
posted @ 2019-03-25 19:06 Zhentiw 阅读(266) 评论(0) 推荐(0)
摘要:In previous post, Arrow Functor with contramap, we have seen how to opreating on params before we invoke the function by using Arrow + contramap. It h 阅读全文
posted @ 2019-03-24 22:06 Zhentiw 阅读(336) 评论(0) 推荐(0)
摘要:This lesson teaches you how arguments passed to a curried function allow us to store data in closure to be reused in our programs and applications. Si 阅读全文
posted @ 2019-03-23 22:10 Zhentiw 阅读(173) 评论(0) 推荐(0)
摘要:To demonstrate the difference between mutability and immutability, imagine taking a drink from a glass of water. If our glass is mutable, when we take 阅读全文
posted @ 2019-03-23 21:58 Zhentiw 阅读(186) 评论(0) 推荐(0)
摘要: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 阅读(343) 评论(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 阅读(278) 评论(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 阅读(223) 评论(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 阅读(247) 评论(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 阅读(163) 评论(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 阅读(196) 评论(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 阅读(249) 评论(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 阅读(195) 评论(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 阅读(305) 评论(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 阅读(254) 评论(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 阅读(434) 评论(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 阅读(285) 评论(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 阅读(283) 评论(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 阅读(266) 评论(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 阅读(273) 评论(0) 推荐(0)

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