Data dodania Pytanie
2017-10-15 15:10 How do I fix ‘Eq a’ has kind ‘GHC.Prim.Constraint’ error in haskell? »
I am writing a small function in Haskell to check if a list is a palindrome by comparing it with it's reverse. checkPalindrome :: [Eq a] -> Bool c...
(3) odpowiedzi
2017-10-15 09:10 Understanding javascript callbacks and formal parameters »
Here is an example of a question that I am slightly confused about. Function one calls function two, and passes it a callback that has a formal para...
(1) odpowiedzi
2017-10-15 07:10 What is my applicative functor not working with Ramda's ap? »
I am trying to learn how to use applicative functors in javascript and came across the ap method. I am trying to use it to combine three arrays like ...
(2) odpowiedzi
2017-10-14 21:10 Converting procedural style methods to functional style »
The code below is supposed to count the black nodes by traversing through the left nodes from the root to the bottom of a red black tree. The number o...
(1) odpowiedzi
2017-10-14 20:10 Executing method on object kotlin »
I'm rather new to Kotlin and am still trying to get to grips with it. Let's say I have this interface: interface A{ fun add() } I have a functi...
(1) odpowiedzi
2017-10-14 18:10 How to overload by different dynamic-type in java8? »
How could I override a method by a dynamic-typed parameter? Or, is their any getting around for similar functionality? Like this: class a{ public...
(3) odpowiedzi
2017-10-13 10:10 How does this C# function composition method work? »
I've occured the following code: public static class FuncUtils { public static Func<T1, T3> Compose<T1, T2, T3> (Func<T1, T2> f...
(2) odpowiedzi
2017-10-13 06:10 Procedural vs. Functional Javascript »
I have a fairly time-critical piece of code in a react app that gets run on all user keystrokes in a form. It has no performance issues in general, bu...
(1) odpowiedzi
2017-10-13 00:10 What is the fluent object model to make this work? »
As practice for writing fluent APIs, I thought I'd make the following compile and run: static void Main(string[] args) { Enumerable.Range(1, 100)...
(2) odpowiedzi
2017-10-12 18:10 With VC 15.4.0, std::function assignment produces C2679 (compiled with 15.3.5) »
The following code compiles just fine with VC 15.3.5: #include <Windows.h> #include <string> #include <memory> #include <optiona...
(0) odpowiedzi
2017-10-12 08:10 How is `[e | x <- xs; y <- ys; ...] = concat[[e | y <- ys; ...] | x <- xs]` »
I am reading "Introduction to Functional Programming First Edition". I came about a rule to translate comprehension as, [e | x <- xs; y <- ys; ...
(1) odpowiedzi
2017-10-12 03:10 Scala - Double every 2nd element in list »
I wanted to write a function that, given a list of Ints, returns a list in which every 2nd element has been doubled. In Haskell the solution seems ea...
(7) odpowiedzi
2017-10-11 18:10 folding and currying with Ruby »
I'm exploring Functional Programming with the Ruby language. Below is my version of a Fold in Ruby. I've tested it on a variety of functions, reverse,...
(2) odpowiedzi
2017-10-11 17:10 Why is the definition of null function in Haskell Prelude so strange? »
The definition of null function in Prelude is the following: null :: [a] -> Bool null [] = True null (_:_) = False ...
(1) odpowiedzi
2017-10-10 17:10 Why does liftM not destroy context? »
I'm confused about how liftM preserves context, specifically in the case of the Writer monad. I've been going through "Learn You a Haskell for Great ...
(2) odpowiedzi
2017-10-10 13:10 Nested map of arrays the FP way »
Given the following arrays: const array1 = ["a1", "b1", "c1", "d1"], array2 = ["a2", "b2"], array3 = ["a3", "b3", "c3"] Is there any ra...
(4) odpowiedzi
2017-10-10 03:10 Scala: deferring a trait method to an implicit class in parent trait's object »
Specifically, I'm trying to extend my Functor typeclass with Applicative. trait Functor[F[_]] { def fmap[A, B](r: F[A], f: A => B): F[B] } obj...
(1) odpowiedzi
2017-10-09 17:10 How to use Monad Transformers to combine different (both pure and impure) monads? »
I'm writing my first Haskell application, and I'm having a hard time understanding the use of Monad transformers. Example code: -- Creates a new use...
(1) odpowiedzi
2017-10-09 16:10 Should React/Redux development be Object Oriented Programming or Functional Programming? »
I have very recently joined the React & Redux ecosystem; and while I can appreciate the clean organisation between components provided by React (p...
(1) odpowiedzi
2017-10-09 09:10 Exhaustive map over a union of typed objects »
I want TypeScript to enforce exhaustiveness when mapping over a union like this: type Union = { type: 'A', a: string } | { type: 'B', b: number ...
(1) odpowiedzi
2017-10-08 22:10 php functional-php library less_than function »
I saw in source code of php-functional library such function : function less_than($b) { return function ($a ) use ($b) { return $a < ...
(1) odpowiedzi
2017-10-08 19:10 Haskell monad flow understanding »
I will restate my questions with examples at the bottom. When I say m or k I am referring to the left and right values in the function call, m >&g...
(4) odpowiedzi
2017-10-08 14:10 Use cases for functor/applicative/monad instances for functions »
Haskell has Functor, Applicative and Monad instances defined for functions (specifically the partially applied type (->) a) in the standard library...
(2) odpowiedzi
2017-10-08 09:10 Map with different types to String »
I am trying to learn some functional programming in Scala. I have this Map: val params: Map[String, QueryMap] = Map( "a" -> SimpleQueryVal("1")...
(3) odpowiedzi
2017-10-07 23:10 C++ store functions that forward universal references »
Is it possible to store a function that has similar behaviour to the following function: void target(int foo, size_t bar) {} void target(std::string ...
(2) odpowiedzi
2017-10-07 21:10 How to map using multiple variables in python? »
I need help with this, I have a list of lists and a list of dictionaries. The list of dictionaries has for its values, list of indexes that point to ...
(1) odpowiedzi
2017-10-07 12:10 Getting a string from a range of possible paths »
I have a scenario where I need to grab the first occurrence of a string from an object, but only if the match occurs in one of the path's that have be...
(1) odpowiedzi
2017-10-06 21:10 Could I ask for physical analogies or metaphors for recursion? »
I am suddenly in a recursive language class (sml) and recursion is not yet physically sensible for me. I'm thinking about the way a floor of square t...
(1) odpowiedzi
2017-10-06 19:10 Functional way to split a map of lists into a list of maps »
I'm a bit stuck on this problem. I feel like I'm "thinking backwards" and it's confusing me a bit. I have a Map[Long, Seq[String]] which I would like...
(4) odpowiedzi
2017-10-06 10:10 OCaml apply anonymous function without argument n-times? »
How would I go about applying a function n-times in OCaml if I don't know the functions argument? I want the call iter(n, fun x -> ...
(2) odpowiedzi
2017-10-06 01:10 Common Lisp Function Return vs Side Effect »
In Common Lisp, if one runs (print "Hello"), he gets this back: "hello" "hello" It is my understanding that one of these is a side effect of the p...
(0) odpowiedzi
2017-10-05 17:10 Haskell - Finding undeclared variables »
AST: data AST = Nr Int | Sum AST AST | Mul AST AST | Min AST | If AST AST AST | Let String AST AST | Var String deriving (Eq, Show) Hi! I need som...
(1) odpowiedzi
2017-10-05 15:10 Picking fields from object with certain RecordType with Sanctuary »
I have an object with options that corresponds to the following record type: const AwsRegionsEnum = $.EnumType( 'AWS/Regions', 'http://docs.aws.a...
(1) odpowiedzi
2017-10-05 09:10 FP sorting function in scala explained »
I've started to learn FP with Scala with the book "Functional Programming in Scala" (Chiusano & Bjarnason, Manning Publications, 2014) There's ...
(1) odpowiedzi
2017-10-04 20:10 How to filter elements from a sublist of objects in scala? »
I have a list of objects[T], each of which has another list of objects[M]. I would like to filter out the inner list M given value for comparison. He...
(2) odpowiedzi