Data dodania Pytanie
2017-02-11 20:02 Currying vs. anonymous function in Scala »
I was comparing two ways of defining a higher-order function in Scala: def f1(elem: Int)(other: Int) = (elem == other) def f2(elem: Int) = (other: I...
(1) odpowiedzi
2017-02-10 17:02 How to reconcile Javascript with currying and function composition »
I love currying but there are a couple of reasons why a lof of Javascript devs reject this technique: aesthetic concerns about the typical curry pat...
(2) odpowiedzi
2017-01-08 16:01 Strange behaviour of list comprehensions »
I'm learning basics of Haskell and trying to solve project Euler's simple tasks: find largest palindrome of 3 digit numbers (100.999). I wrote this co...
(1) odpowiedzi
2017-01-04 22:01 React: Is it possible to call a higher-order component within a container component? »
In my codebase I have a higher-order component (HOC) I use to add all the input validation functionality to a given component. It works great when us...
(3) odpowiedzi
2016-12-19 23:12 How does lazy-evaluation allow for greater modularization? »
In his article "Why Functional Programming Matters," John Hughes argues that "Lazy evaluation is perhaps the most powerful tool for modularization in ...
(1) odpowiedzi
2016-12-17 16:12 Scala: Higher order function to return the union of sets »
I am working on the following scala higher order function: def after(M: Set[Expression], n: String): Set[Set[Expression]] = { M.map((expr: Expression...
(1) odpowiedzi
2016-12-12 16:12 Abstract over repeated flatMap »
I am trying to generalize repeated, nested flatMap but not sure if one exists. The following code will produce all combinations of n choose 3, : d...
(1) odpowiedzi
2016-12-09 00:12 Markov processes with higher order functions in R »
I'm looking for a clean way to run simulations where each iteration depends on the result of the preceding iteration in a "functional style." For exam...
(0) odpowiedzi
2016-12-08 20:12 Return the maximum number in each array using map »
function each(coll, f) { if (Array.isArray(coll)) { for (var i = 0; i < coll.length; i++) { f(coll[i], i); } } else { for (va...
(5) odpowiedzi
2016-12-06 18:12 Haskell Higher Order Functions »
I have a homework on higher order functions in Haskell and I'm having a little trouble getting started. If I could get some help and explanation on t...
(1) odpowiedzi
2016-11-15 20:11 How to refactor (if / elsif / elsif) chain in Scala? »
I have a chain of if / else if statement that are not self explanatory. I would like to extract each into its own function with a clear explanatory na...
(7) odpowiedzi
2016-11-05 00:11 Write the recursive function adjuster »
Write the recursive function adjuster. Given a list of type x, an int and an element of type x, either remove from the front of the list until it is t...
(2) odpowiedzi
2016-10-14 21:10 How to pass the initial state as props for my Higher Order Component? »
I have a Slider component that doesn't handle its own state, instead, it's wrapped in another component called SliderDrag that manages the state and p...
(1) odpowiedzi
2016-09-02 13:09 Functional way to get or update »
I have a cache and have two functions to get an item from the cache and put an item to the cache. When getting item(from the cache), if key not exist...
(3) odpowiedzi
2016-08-20 01:08 Why is it useful to have an anonymous function stored as a variable, and pass it to higher order functions? »
I am working on my understanding of functional programming and have a question. In this example* an anonymous function is assigned to the variable is...
(4) odpowiedzi
2016-07-22 00:07 Functional Programming: Are maps sequential? Implications for closures »
I will illustrate with Julia: Suppose I have a function counter() that is a closure. function mycl() ...
(3) odpowiedzi
2016-07-03 04:07 Is it possible to get an unbounded map function on a set? »
Represent a set by its characteristic function, for instance, the set of integers should be like type Set = Int => Boolean And given some ...
(0) odpowiedzi
2016-05-27 19:05 Compose functions into another function »
Is there a function for Haskell in the standard library which takes three functions and returns a function which applies the return values of the firs...
(2) odpowiedzi
2016-05-25 01:05 How can JavaScript functions expanded? »
How can JavaScript functions expanded? I need a function expand(fn), s.t. given the functions below: function f() { console.log('f'); } functio...
(0) odpowiedzi
2016-05-20 01:05 Angular.js - Why use a function to return a function? »
I'm wondering, why do I sometime see functions that returns a function? For example this answer from this question: AngularJS custom filter function...
(4) odpowiedzi
2016-05-13 00:05 What is a purpose of Zap Functor and zap function in Haskell? »
I came across this construction in Haskell. I couldn't find any examples or explanations of how can I use zap/zapWith and bizap/bizapWith in real code...
(2) odpowiedzi
2016-05-09 18:05 React.cloneElement: pass new children or copy props.children? »
I'm confused by the third "children" parameter of React.cloneElement and it's relation to this.props.children. I followed this guide on higher order ...
(0) odpowiedzi
2016-03-14 10:03 Optimization of consecutive map/filter/fold calls »
Let's say I have a big list on which I'd like to execute multiple map, filter and fold/reduce calls. For clarity and expressiveness this should be don...
(1) odpowiedzi
2016-02-26 15:02 How can a more flexible, more expressive function composition operator be implemented? »
Function composition is a wonderful tool for code reuse by combining small, extremely specialized functions to solve complex problems. However, it has...
(0) odpowiedzi
2016-02-10 04:02 Functional Programming in Swit to distribute array elements to correct "buckets" »
I'm new to functional programming. My problem is that I have a main array and a fixed number of "destination" arrays. I would like to distribute the e...
(1) odpowiedzi
2016-01-27 03:01 Why is Haskell (GHC) so darn fast? »
Haskell (with the GHC compiler) is a lot faster than you'd expect. Used correctly, it can get close-ish to low-level languages. (A favorite thing for ...
(2) odpowiedzi
2016-01-24 15:01 How to implement a more general partial reduce to mimic early exit / short circuiting? »
reduce (aka foldL in FP) is the most general iterative higher order function in Javascript. You can implement, for instance, map or filter in terms of...
(1) odpowiedzi
2016-01-14 14:01 Modify element(s) in a list where a condition is true »
case class Person(name: String, age: Int, qualified: Boolean = false) val people: List[Person] = .... val updated: List[Person] = people.map(person ...
(2) odpowiedzi
2015-12-18 17:12 Returning Values in Javascript Functions »
I came across this answer while understanding closures by @Jacob Swartwood http://stackoverflow.com/a/6472397/3179569 and I could not understand how ...
(3) odpowiedzi
2015-12-16 03:12 Why doesn't my filter function work? (Javascript). »
What I am trying to accomplish, being able to use the filter function to filter out the people that have the age: 21 and the color: blue. Any sugges...
(4) odpowiedzi
2015-12-08 02:12 R: Using user input to pass functions and parameters as parameters to higher-order functions »
I am not sure if this is doable (at least the way I am trying to do this), but I really hope so. I have a fairly complex testing environment that I a...
(1) odpowiedzi
2015-11-08 18:11 Swift higher order function (Church pair aka cons) with generic parameter types not accepting input parameter types »
I was messing around with the functional programming in Swift 2.1, trying to implement the Church encoding pair/cons function (cons = λx λy λf f x...
(1) odpowiedzi
2015-10-13 12:10 K / Kestrel Combinator for monads? »
implicit class KComb[A](a: A) { def K(f: A => Any): A = { f(a); a } } Given this implementation of the K combinator, we can chain method calls ...
(0) odpowiedzi
2015-10-05 04:10 Is there evidence for a correlation between FP Higher Order Functions and operations on DNA? »
The following commentator writes: Nature programs in strands of DNA and executes by zip, unzip, take, drop, filter, fold, repeat, cycle, and ++ ...
(0) odpowiedzi
2015-09-27 04:09 How to create a function that encodes run-length using fold_right? »
I created a function and helper function that find the number of repeating elements in a list, and what those elements. let rec _encode l x = match...
(1) odpowiedzi