Data dodania Pytanie
2017-09-23 12:09 Is it possible to express kotlin 'with' method equivalent in Scala? »
Kotlin Standard lib contains the 'with' method that receives an object and a method of that object defined as: public inline fun <T, R> with(re...
(1) odpowiedzi
2017-06-19 00:06 Functional Programming scala »
I was following "Functional Programming Principles in Scala" from coursera and in the second week the assignments is about "Purely Functional Sets" We...
(2) odpowiedzi
2017-05-10 21:05 Are Church encoded sum types a proper alternative in an untyped language? »
I have been struggling for quite some time with the idea of sum types in Javascript. The language includes neither native sum types nor pattern matchi...
(1) odpowiedzi
2017-05-05 10:05 Functional programming axioms »
I'm learning functional programming with Clojure, and want to deepen my theoretical understanding of functional paradigm (not just the syntax of Cloju...
(3) odpowiedzi
2017-04-10 17:04 Why doesn't Spark RDD support "flatten" »
Have a look at this snippet [*]: val la = List(Array(2, 3, 5), Array(7, 11, 13)) la.flatten returns res1: List[Int] = List(2, 3, 5, 7, 11, 13) N...
(1) odpowiedzi
2017-04-10 15:04 How can I convert this large factorial function to a higher-order function? »
The following code uses a cache object outside of the factorial function. The factorial function itself is large which has too many concerns of findin...
(1) odpowiedzi
2017-03-19 22:03 Unit testing higher order functions in F# »
Take the following F# example: let parse mapDate mapLevel mapMessge (groups : string list) = { DateTime = mapDate( ...
(1) odpowiedzi
2017-03-03 11:03 Unpack vector into function arguments »
I have a function with four parameters, e.g. fun <- function( x, a, b, c ) { sin( x * a ) * exp( -x * b ) + x * c } I'd like to convert that...
(2) odpowiedzi
2017-02-28 13:02 Can functors or monads respectively be expressed solely with higher order functions? »
I'm attempting to implement functors in Javascript without using container types ([]/{}). Hence, I solely utilize pure higher order functions to const...
(1) odpowiedzi
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