Data dodania Pytanie
2016-12-31 16:12 How to check/predicate function type in Swift? »
For example: func f(x: Int) -> Int { return x } func h(f: @escaping (Int) -> Any) { if (f is (Int) -> Int) { print(f(1)) } els...
(3) odpowiedzi
2016-12-31 11:12 How to use cats and State Monad »
I've used cats for the first time to solve day 1 of advent of code and I'm wondering if it's possible to improve things. Given a method update with t...
(1) odpowiedzi
2016-12-31 01:12 Why every? function returns true with empty vector in Clojure? »
I came across this weird behaviour: (every? true? []) => true (every? false? []) => true (every? odd? []) => true And list goes like tha...
(1) odpowiedzi
2016-12-30 18:12 How to make a class fully immutable in Scala »
I am trying to make the following class immutable. I know the theory of how to do this but I think my implementation is wrong. Can you help? Thanks ...
(2) odpowiedzi
2016-12-30 09:12 How do I use functional chaining with composition in javascript? »
I have this code that is building a url endpoint taking in different parameters: const query = (obj) => { let starter = 'query=' let que...
(3) odpowiedzi
2016-12-30 02:12 Haskell longest contiguous series of elements in a list »
I'm new to functional programming and the language haskell. I'm trying to determine the length of the longest contiguous series of elements in a list ...
(3) odpowiedzi
2016-12-29 22:12 Checking if Ticker is in another list, then adding a new key [RamdaJS] »
I'm trying to use Ramda to compare 2 lists, find which tickers in the tickersList are also in the portfolioTickers. If one is in the portfolio list as...
(2) odpowiedzi
2016-12-29 16:12 Tail Recursive function for the sum of fractions »
I am trying to convert this recursive function into a tail recursive function def sumOfFractions(n: Int): Double = { require(n > 0, "Parameter n...
(2) odpowiedzi
2016-12-29 11:12 Applicative functors vs monad composing performance in Scala »
I have two monad instances val a: M[A] and val b: M[B]. Would there be any performance difference in the following code cases? def f: (A, B) => C...
(1) odpowiedzi
2016-12-28 21:12 How to compose two functions whose outer function supplies arguments to the inner function »
I have two similar codes that need to be parsed and I'm not sure of the most pythonic way to accomplish this. Suppose I have two similar "codes" sec...
(1) odpowiedzi
2016-12-28 13:12 Can I have an array of objects with a custom toString in JavaScript? »
I've got an array of objects. (Use case might be solitaire cards). I want to embed a toString for debugging them. I'm using the following (simplif...
(1) odpowiedzi
2016-12-28 09:12 Is it possible to add a value when returning a function from a recursive function being chained? »
I'm attempting to make a recursive function that adds number values, and returns itself. Here's what I have so far. const recursivo = (...v) => v ...
(0) odpowiedzi
2016-12-27 19:12 Scala: Why this function is not tail recursive? »
I have such implementation of Merge Sort: import scala.annotation.tailrec object MergeSort { def sortBy[T]: ((T, T) => Int) => Seq[T] => ...
(1) odpowiedzi
2016-12-27 15:12 How to implement breadth first search in Scala with FP »
I'm wondering how to implement a Breadth-first search in Scala, using functional programing. Here is my first, impure, code : def bfs[S](init: S, ...
(2) odpowiedzi
2016-12-27 11:12 Pure functions and Java »
I have several doubts about Java and pure functions. As far as I know, a pure function is a function for which these two statements hold: No side-ef...
(1) odpowiedzi
2016-12-26 22:12 on using rxjs to update props of a react functional stateless component »
I thought I could use an observable to send in new props every second and have a react (functional, stateless) component thereby update itself. I am n...
(1) odpowiedzi
2016-12-26 15:12 C# - match ID to filename using functional principles »
I'm rewriting an old C# project from scratch trying to figure out how it can be improved with the use of functional design. So far I've stuck with a c...
(2) odpowiedzi
2016-12-26 12:12 LISP how to write this function without using LOOP »
i wrote this function but i have been told i can't use the loop inside of it, i have no idea how to modify it in order to remove the loop. any suggest...
(1) odpowiedzi
2016-12-26 00:12 List comprehension equivalent to map on two lists in parallel »
I understand that with one list argument map() can be replaced by a list comprehension. For example map(lambda x : x**2, range(5)) can be replaced ...
(1) odpowiedzi
2016-12-25 16:12 Automatic detection of domain for dependent type function in Idris »
Idris language tutorial has simple and understandable example of the idea of Dependent Types: http://docs.idris-lang.org/en/latest/tutorial/typesfuns...
(1) odpowiedzi
2016-12-25 09:12 Haskell couldn't match expected type [char] with actual type IO »
I just started learning Haskell, and i'm on stuck on this error among a bunch of others i'm trying to print all the characters in the char list recu...
(2) odpowiedzi
2016-12-25 05:12 How to preload a Ramda curried function with item of an Array? »
I have tagsList which has about 20 tags, and termIds which is an array of up to 3 tag ids. I'm trying to find the tags that match the ids in termIds ...
(3) odpowiedzi
2016-12-24 17:12 re-write without using set, setf or setq »
i need some help to re-write this function in common lisp without usin SET, SETF or SETQ (i can't also use loops), i hope some one can help me. here i...
(1) odpowiedzi
2016-12-24 15:12 Filtering function for an arbitrary nested list »
I can't find out how to write this function as a lambda because of the double conditional: def f(e): if not isinstance(e,list): if e >...
(2) odpowiedzi
2016-12-24 12:12 Nested functions performance (F#) »
Are there any performance issues with nested functions in F#? If I have a function which is called on every item in an array, and this function has n...
(1) odpowiedzi
2016-12-24 07:12 How can I search through a 2D array without for loops? »
I have a Vec<Vec<char>> and I want to find all the x,y positions of a specific character, let's say 'x'. I can use a double for loop with ...
(1) odpowiedzi
2016-12-23 21:12 How can I write the factorial function with reduce and range? »
function range(start, end) { var acc = []; for (var i = start; i < end; i++) { acc.push(i); } return acc; } Using the range function ...
(5) odpowiedzi
2016-12-23 08:12 Converting functors (F[A] => G[A]) in Scala (cats or scalaz) »
Is there a typeclass in Cats or Scalaz that converts between different container types? For example Option ~> Try Try ~> Future Try ~> Either Opti...
(1) odpowiedzi
2016-12-23 07:12 How does Scala return in function »
I implemented to find max value in the list. I know that in Scala, You don't have to use 'return', just drop it. So I wrote like this, def max(xs: L...
(2) odpowiedzi
2016-12-22 23:12 r remove outliers from a list of data.frames and make a new list of data.frames? »
I have a List of 6 in a data.frame It has 3 columns: id, T_C, Sales T_C is TEST or CONTROL Someone helped me here and I learned how to find the me...
(1) odpowiedzi
2016-12-22 17:12 Warning on mutable Java variables in Eclipse »
I'm interested in moving toward more functional constructs in Java, and was wondering if there was a way in Eclipse to have it warn if I have mutable ...
(1) odpowiedzi
2016-12-22 16:12 Haskell getting value of Either from Get monad »
I am a Haskell noob feeling stuck on a rather simple function I am attempting to perform. Ultimately my goal is to read a strict ByteString, use the ...
(1) odpowiedzi
2016-12-21 23:12 How can I map list.__contains__? »
I'm trying to map the list.__contains__, but am getting the following error In [31]: map(list.__contains__(3), [[1,2],[1,3]]) -----------------------...
(1) odpowiedzi
2016-12-21 17:12 Why don't more languages use an immutable model like Clojures? »
Most of my understanding of how clojure handles immutables comes from this. This seems really clever to me; it makes things like copying and changing ...
(1) odpowiedzi
2016-12-21 15:12 Why does not Clojure allow us to write functions unordered? »
One of the things that I don't like in Clojure is that I need to define functions in order like this: (defn a [] 1) (defn b [] (+ 1 (a))) If Clo...
(1) odpowiedzi