随笔分类 - Javascript
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Implement a job scheduler which takes in a function f and an integer n, and calls f after nmilliseconds
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:/**@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(...
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文

浙公网安备 33010602011771号