Data dodania Pytanie
2017-06-05 15:06 how to pipe functions, when a promise in the promise in the middle checks authorization? »
i'm trying to compose some functions together: compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); checkAuthorization ...
(2) odpowiedzi
2017-06-04 19:06 F# - Turn simple for loop into more functional construct »
I have this simple "Investment" type with a "lifetime" property: type Investment = { PurchasePayment: float; Lifetime: float; TaxWriteoff: float; Res...
(4) odpowiedzi
2017-06-04 11:06 ADT with for comprehension »
I have an use case where I need to use for comprehension with ADT in Scala. I could write the same code using flatMaps but it seems a bit unreadable. ...
(1) odpowiedzi
2017-06-04 09:06 When using java 8 map, filter and collect, does it create new objects or modify existing objects? »
I have the code below where I am doing filtering using a filter and replace function inside my map and then I am doing a collect to replace my origina...
(2) odpowiedzi
2017-06-03 20:06 Yesod Persist - understanding selectList »
I'm extremely new to Yesod, and I'm having trouble understanding how some of the code works. There's only one book on it and it's not super in depth. ...
(0) odpowiedzi
2017-06-03 09:06 Case object extending class with constructor in Scala »
I am a beginner in Scala and was playing around to learn more about Abstract data types. I defined the following definition to replicate Option type: ...
(3) odpowiedzi
2017-06-02 12:06 calling filter, find (array methods) lazily on all iterables »
The question is pretty simple: is there any way to call Array methods like filter, find, map, etc. not only on arrays, but on any iterable? filter, f...
(1) odpowiedzi
2017-06-02 11:06 How do I write a 100% pure memoize function? »
For example, say this is my function: let fib = n => { switch (n) { case 0: return 0 case 1: return 1 default: return fib(n - 1) + f...
(1) odpowiedzi
2017-06-02 02:06 Java 8 - Find Leaders in an Array »
I am trying to learn the features of Java 8 especially the functional programming aspect of it. So I am trying to solve a problem: Find Leaders in an ...
(2) odpowiedzi
2017-06-01 16:06 Looking for a functional programming pattern to prevent from initializing a module every time »
I currently work on a javascript application which is organized this way: I have a API module that takes care of all api calls in my application. In...
(1) odpowiedzi
2017-06-01 11:06 Recursive use of Javascript returns undefined »
I'm trying to write a recursive function with Javascript, but apparently I miss something and I cannot make it return at the point that I want. In the...
(2) odpowiedzi
2017-06-01 00:06 Alternative ways to parse local JSON file with functional approach? »
Below is the way I usually use to safely parse local JSON data in Node environment, mostly config files and some other relevant data: const fs = requ...
(1) odpowiedzi
2017-05-31 18:05 Can lazy evaluation be implemented by a monadic type? »
I'm currently studying lazy evaluation in conjunction with monads in Javascript and what use cases may evolve from these. So I tried to implement a la...
(3) odpowiedzi
2017-05-31 16:05 React Functional Component Inheritance »
i created a React functional component that is a wrapper around the react-data-grid component. now i need a second component that is exactly the same ...
(1) odpowiedzi
2017-05-30 22:05 Scala: Convenience construtor, a constructor that is lazy and requires no delay »
I have been given the task to create a so-called "convenience constructor" which should serve the purpose of constructing an instance of the below-giv...
(1) odpowiedzi
2017-05-30 20:05 Is it possible to dynamically create delegate to the method currying some parameters (and do it without expression's compile, and DynamicInvoke)? »
Is it possible to dynamically create delegate to the method currying some parameters (and do it without expression's compile, and DynamicInvoke)? Wit...
(1) odpowiedzi
2017-05-30 17:05 What are isomorphism and homomorphisms »
I tried to understand isomorphism and homomorphisms in context of programming and need some help. In the book FPiS it explains: Let start with ...
(2) odpowiedzi
2017-05-29 19:05 lambda expression vs static method »
I had a question about reusability of lambda expression without code duplication. For example if I have a helper method I can easily code it as a stat...
(4) odpowiedzi
2017-05-29 15:05 How to automatically generate the predictor function associated with a formula? »
Consider, for example, the following regression linear.model <- lm(formula = y ~ x1 + x2 + x1:x2, data = my.data) ...and the following closure ...
(0) odpowiedzi
2017-05-29 04:05 How does variable binding work with recursion in Haskell? »
I was reading about Haskell and it stated that once a variable is bound to an expression it cannot be rebound for example x = 10 x = 11 Assign.hs:2:...
(3) odpowiedzi
2017-05-28 21:05 Prolog: uncaught exception: error(syntax_error('user_input:4 (char:7) »
I get the following error message when I try to run my Prolog code. I am very new to this language and am having a lot of trouble finding my error. I ...
(0) odpowiedzi
2017-05-28 17:05 Scala: if inside match case »
Is there any way to put a if inside a match case in scala? Something like this: def createSchedules(listTask: List[TaskOrder], physicalResources: Li...
(3) odpowiedzi
2017-05-28 01:05 Scala: get list with the first element of three lists not repeating any element »
I have a scala List[List[Person]] with the following elements: Person(Antonio) Person(Maria) Person(Joao) Person(Antonio) Person(Susana) Person(Laur...
(2) odpowiedzi
2017-05-27 23:05 Clarification on a Haskell function type argument »
On a recent worksheet I was asked to explain why the function f, in: f g x = g (g x) x has no type. I'm quite new to Haskell and I'm quite confused ...
(3) odpowiedzi
2017-05-27 21:05 Kotlin/Java functional and immutable way of collecting a map in a map »
Currently i'm reading a file through the Java API and adding items to a map through the method foreach which forces me to make use of the mutablemap. ...
(2) odpowiedzi
2017-05-27 18:05 F# calling function that returns record in for loop only executes once »
I mainly work in C# and am new to F#/function languages and I'm having a problem with a pretty simple program. I have a function that creates a record...
(1) odpowiedzi
2017-05-26 15:05 reverse using foldLeft in scala »
def foldLeft[A, B] (as: List[A], z: B) (f: (B, A) => B) : B = as match { case Nil => z case Cons(x, xs) => foldLeft(xs, f(z, x))(f) } de...
(2) odpowiedzi
2017-05-26 09:05 Why future has side effects? »
I am reading the book FPiS and on the page 107 the author says: We should note that Future doesn’t have a purely functional interface. This i...
(3) odpowiedzi
2017-05-26 05:05 Haskell - How would I run a list of state monads? »
I'm somewhat new to Haskell and I'm having some trouble with the State monad. I have created the following types. Stat a has a monoid, functor, appli...
(1) odpowiedzi
2017-05-25 20:05 What should a "higher order Traversable" class look like? »
In this answer I made up on the spot something which looks a bit like a "higher order Traversable": like Traversable but for functors from the categor...
(1) odpowiedzi
2017-05-25 18:05 Scala way of merging tuples in a list using functional programming techniques »
Say I have: val list: List[(Long, Boolean)] = List((0, false), (0, true), (1, true), (1, true)) and in the end I want: List((0, false), (1, true))...
(2) odpowiedzi
2017-05-25 01:05 SML Polymorphic references in signatures »
Is there a way to make polymorphic references constants in signatures? This code compiles, but is not what I need: signature NAME = sig type 'a ...
(1) odpowiedzi
2017-05-24 23:05 How do I embed a module's UI into a region of an application's shell? »
How do I embed a module's UI into a region of an application's shell? I have a Login module that I want to pull into a region of my Elm application. ...
(1) odpowiedzi
2017-05-24 21:05 When to use Clojure's closures? »
I've written couple of Clojure programs, but I can barely remember that I used closures. What are the best use cases for using closures in Clojure? ...
(6) odpowiedzi
2017-05-24 16:05 JavaScript : Make an array of value pairs form an array of values »
Is there an elegant, functional way to turn this array: [ 1, 5, 9, 21 ] into this [ [1, 5], [5, 9], [9, 21] ] I know I could forEach the array an...
(8) odpowiedzi