Data dodania Pytanie
2017-01-11 23:01 takeWhile, dropWhile laziness java9 »
In scala those methods works fine but in java9 dropWhile works differently I think. Here is example for takeWhile Stream.of("a", "b", "c", "de", "f"...
(4) odpowiedzi
2017-01-11 15:01 why Partial function in scala is giving run time error for input 0? »
I am expecting my partial function to discard for input 0 , but instead it is giving match error . Will you please explain exactly why is it happening...
(3) odpowiedzi
2017-01-11 08:01 Can a convolution function written in tail recursive form? »
I have a function that I want to write in tail recursive form. The function calculates the number of ways to get the sum of k by rolling an s sided di...
(2) odpowiedzi
2017-01-10 14:01 Conditional "assignment" in functional programming »
I am programming something that doesn't have side-effects, but my code is not very readable. Consider the following piece of code: (let [csv_data (if...
(4) odpowiedzi
2017-01-10 14:01 How can I use fold with a Result return value? »
I have a function: fn test<T: FromStr>(text: &str) -> Result<T, SaleError> SaleError is my custom error struct in this case. I ...
(2) odpowiedzi
2017-01-10 05:01 python high order function: generic functions calls with parameter list »
I am looking for a high order function in python that takes in a function as parameter and a list of corresponding parameters, and call the function o...
(2) odpowiedzi
2017-01-09 20:01 Monads as Monoids in practice »
I am trying to understand the relationship between monads and monoids in more practical ways. I apologize in advance if this question makes no sense, ...
(1) odpowiedzi
2017-01-09 17:01 Mixing fmap and bind (>>=) »
In Haskell, when I have to mix calls to fmap/<$> and >>=/=<<, I invariably end up with lots of parenthesis. For example, here I'm c...
(1) odpowiedzi
2017-01-09 00:01 How to fold a tree without making it an instance of Foldable? »
I've defined my tree as follows: data Tree a = Tip | Node (Tree a) a (Tree a) deriving Show and made it an instance of a Functor: instance F...
(1) odpowiedzi
2017-01-08 19:01 Numerical Streams Example Optimization »
I am reading "Java 8 In Action" (by Raoul-Gabriel Urma, Mario Fusco and Alan Mycroft), section 5.6.3, pages 116 and 117. The code that is presented h...
(1) 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-08 01:01 Programming Chess in Functional programming »
A year ago I programmed a chess AI using the Alphabeta prunning algorithm. This was relatively straight forward to do in c++. One of the main issues I...
(2) odpowiedzi
2017-01-07 23:01 Is this a common design pattern? »
i use the following pattern/style alot in my applications/programs and want to know if this is a common pattern that i don't know. When i must write...
(3) odpowiedzi
2017-01-06 17:01 Swift 3: Filter a range »
In Swift 2 it was possible to filter a range like this: let range: Range<Int> = 1..<100 let mult4 = range .filter{n in n % 4 == 0} In ...
(3) odpowiedzi
2017-01-06 16:01 Does PowerShell have a "window" function? »
I was looking for a "window" function like F#'s Seq.windowed or the Reactive extensions Window. It looks like it would be provided by the likes of Sel...
(2) odpowiedzi
2017-01-06 13:01 How to accurately measure the effort required to reduce a λ-term? »
Blockchains such as Ethereum use a stack-register based language on their smart-contract processing virtual machines. That model is very convenient be...
(0) odpowiedzi
2017-01-05 16:01 How to join array of optional integers to string? »
Given [Int?], need to build string from it. This code snippet works let optionalInt1: Int? = 1 let optionalInt2: Int? = nil let unwrapp...
(5) odpowiedzi
2017-01-05 16:01 How to use kwarg arguments when evaluating a function using map functionality »
Below is an example of a test method which is evaluated using a for loop and a kwarg argument. def test(first_arg='_', second_arg='_'): return 'f...
(1) odpowiedzi
2017-01-05 16:01 Using functional programming properly: how do I use .map() efficiently here? »
I've got two arrays: hobbieList and hobbieTypes. I want to separate the elements in hobbieList, depending on what's the value of their index, in the h...
(5) odpowiedzi
2017-01-04 15:01 Constrained Value Types in Haskell »
Is it possible to define constrained types in Haskell, i.e. I would like to be able to express, Prelude> let legalCharacters = ' ':['A'..'Z'] Prel...
(1) odpowiedzi
2017-01-04 13:01 How to bundle values into set length lists in Haskell? »
Trying to write a function in Haskell that bundles a list of xs into lists of size n e.g. the result of bundle 3 [1..10] should be [[1,2,3],[4,5,6],[7...
(1) odpowiedzi
2017-01-04 01:01 What are those math functions end with apostrophe in Clojure? »
There are some functions(math fns) that their name end with apostrophe. Like: +', *', -' What is the difference between non-apostrophe and apostroph...
(1) odpowiedzi
2017-01-03 19:01 Elegant way to delete single key of from each element in iterable »
Is it possible to manipulate each dictionary in iterable with lambdas? To be clarify, just want to delete _id key from each element. Wonder If there...
(2) odpowiedzi
2017-01-03 16:01 Functional programming / Ramda: Creating a new object by picking nested properties »
Functional programming newbie here. I have this object: { _id: '2014d5db-55dc-4078-ae87-382c226d0785', _source: { phone: '00447827434313', ...
(1) odpowiedzi
2017-01-03 05:01 How in Scala , trait "Null" can be instantiated producing "null"? »
From the API doc I found that Null is a trait, but it says its sole instance is null. abstract final class Null extends AnyRef Null is - toget...
(1) odpowiedzi
2017-01-02 17:01 How to fold a collection of endomorphism with cats »
Given a function def f(i: I) : S => S I would like to write a pretty common combinator g def g(is : Seq[I], init: S) : S The easy implementat...
(1) odpowiedzi
2017-01-02 17:01 Negating Java 8 reference to Predicate method »
In Java 8, it is possible to refer to unary methods which return a boolean/Boolean (e.g. Collection.contains(Object)) using method reference syntax, r...
(0) odpowiedzi
2017-01-02 02:01 Functional Programming: What's the difference between using a closure and using the bind method? »
I'm working on a tutorial that explains functional programming. He asked me to come with a solution and it worked, but his solution uses the .bind met...
(2) odpowiedzi
2017-01-01 21:01 contramap method doesn't make any sense to me »
I am reading about the contramap method in Functors. What I understand about them is that if I have a type class F[B] (for example List[Int]) and I ha...
(0) odpowiedzi
2017-01-01 20:01 How to optimize data generation for numpy call »
I'd like to know how to make the following code shorter and/or more efficient. Could I (or should I) get rid of the for loop by using a functional me...
(2) odpowiedzi
2017-01-01 18:01 Retry once using functional interface »
I'm new to functional programming (and Java) and I want to create something nice using it, but cannot figure out how. I'm using BiConsumer (java.util...
(0) odpowiedzi
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