Functional programming is a programming paradigm which primarily uses functions as means for building abstractions and expressing computations that comprise a computer program.
0
votes
2answers
28 views
zip function for Java
Is there some standard API or established third party library (I am thinking commons or Guava) that provides in Java the equivalent of zip or map vector function in languages like Ruby or Clojure?
...
0
votes
2answers
45 views
How do I filter a list with functional programming in scala?
I have two lists:
val list1 = List("asdf", "fdas", "afswd", "dsf", "twea", "rewgds", "werwe", "dsadfs");
val list2 = List();
I want to filter all items from list1 and setup list2 so that it only ...
0
votes
2answers
101 views
Initializing a val lately
Is it possible to do that in Scala using only val:
class MyClass {
private val myVal1: MyClass2 //.....????? what should be here?
def myMethod1(param1: Int) = {
myVal1 = new MyClass2(param1)
...
3
votes
1answer
89 views
Pluggability in a functional paradigm
What is the proper functional way to handle pluggability in projects? I am working on a new opensource project in F# and can not seem to get the object oriented idea of plugins and interfaces out of ...
0
votes
3answers
60 views
Caching function result on c#
Let us have this kind of code:
Function<int,int> someFunc=(x)=>{
//SomeCalc
return y;
}
than I want to use my function that way:
int result;
if(someFunc(k)!=0)
{
...
0
votes
1answer
24 views
How to setup and teardown functional test data in Geb grails
I have many working/passing functional geb/spock tests (each extending GebReportingSpec) that are testing a web application with test data all created from the BootStrap.groovy at the beginning of the ...
0
votes
2answers
120 views
Unifying Types in Haskell
I'm kind of stuck with an assignement concerning my exams. I want to find out the types of those two functions by applying the unifying algorithm by hand:
map map
(\x -> x >>= (\y -> y))
...
4
votes
1answer
168 views
Functional non recursive approach to looping in Haskell
I use Haskell for my programming during leisure these days. Being a programmer in imperative languages for over 8 years, it is tough to wrap my head around some functional constructs (especially the ...
3
votes
2answers
88 views
FoldLeft using FoldRight in scala
While going through Functional Programming in Scala, I came across this question:
Can you right foldLeft in terms of foldRight? How about the other way
around?
In solution provided by the ...
0
votes
2answers
126 views
Designing Testable Functional Code
Sorry for bad question:
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this ...
9
votes
0answers
284 views
Are there problems that can't be solved efficiently without arrays? [duplicate]
For someone used to imperative programming, it's sometimes hard to write efficient code in functional languages without using arrays/vectors. However, it seems there's always a smart way of doing it. ...
1
vote
3answers
53 views
Loops and variable scope in R
I have following for loop in R:
v = c(1,2,3,4)
s = create.some.complex.object()
for (i in v){
print(i)
s = some.complex.function.that.updates.s(s)
}
# s here has the right content.
Needless ...
3
votes
1answer
72 views
Compute a chain of functions in python
I want to get the result of a chain of computations from an initial value. I'm actually using the following code:
def function_composition(function_list, origin):
destination = origin
for ...
1
vote
1answer
50 views
clojure sum of all the primes under 2000000
It's a Project Euler problem .
I learned from Fastest way to list all primes below N in python
and implemented a clojure :
(defn get-primes [n]
(loop [numbers (set (range 2 n))
primes []]
...
2
votes
3answers
110 views
Built in f# operator to compose functions with the same input but different outputs?
I understand the << compose operator takes two functions that both take in and return the same type. e.g. (lhs:'a -> 'a) -> (rhs:'a -> 'a) -> 'a
I often find myself wanting ...