Functional programming is a programming paradigm which makes it easy to create, reason about, and compose functions.
10
votes
5answers
543 views
What is the functional-programming alternative to an interface?
If I want to program in a "functional" style, with what would I replace an interface?
interface IFace
{
string Name { get; set; }
int Id { get; }
}
class Foo : IFace { ... }
Maybe a ...
3
votes
1answer
213 views
Is Rebol a functional programming language?
I ran into Rebol and I was wondering about it.
I ran into the following script from here:
use [feed questions answers][
feed: load-xml/dom http://stackoverflow.com/feeds/tag/rebol
...
15
votes
10answers
2k views
How to write useful Java programs without using mutable variables
I was reading an article about functional programming where the writer states
(take 25 (squares-of (integers)))
Notice that it has no variables. Indeed, it has nothing more than three ...
2
votes
1answer
54 views
Practical reference for learning about graph reduction
Are there any practical references (with actual examples) for getting started implementing a small, lazy functional programming language with graph reduction? A reference that included the lexing and ...
4
votes
1answer
226 views
Functional reactive programming — is Fay expressive enough?
So I'm doing a fairly involved javascript/html client with lots of ajax calls and other involvements of callback-ism. I'm entertaining the thought of using Fay for this purpose. I'm aware of Elm. ...
4
votes
2answers
152 views
Who first coined the term Higher Order Function and/or First Class Citizen?
I've come to understand that long before Haskell, O'Caml or LISP, higher order functions were an academic research subject and in mathematics, Schönfinkel (in 1967) and Haskell Curry (in 1968) already ...
6
votes
2answers
267 views
What's a good math textbook to have on my desk while studying Haskell?
I just started learning Haskell and it seems like you can't get too far in the language without being comfortable ( or at least exposed ) to certain branches of mathematics. Unfortunately I have major ...
69
votes
13answers
34k views
What is the advantage of currying?
I just learned about currying, and while I think I understand the concept, I'm not seeing any big advantage in using it.
As a trivial example I use a function that adds two values (written in ML). ...
8
votes
2answers
211 views
What's the difference in content between Chris Okasaki's 1996 thesis and 1999 book, Purely Functional Data Structures?
I want to read Purely Functional Data Structures. I've easily found the thesis (which is freely available as a PDF), but see that there's a book available also. So I'd like to know what the ...
7
votes
1answer
82 views
What is the current state of SECD and SKI machine use and research?
I'm doing some independent research/study with a professor who's a very functional guy. The goal is to examine more of what's happening behind the scenes with functional languages than we normally ...
7
votes
1answer
142 views
Better to use error monad with validation in your monadic functions, or implement your own monad with validation directly in your bind?
I'm wondering what's better design wise for usability/maintainability, and what's better as far as fitting with the community.
Given the data model:
type Name = String
data Amount = Out | Some | ...
8
votes
0answers
408 views
Why (or why not) are existential types considered bad practice in functional programming? [closed]
I've sometimes heard that using existential data types is sort of a bad practice in functional programming and that there are ways how to avoid it. I'd like to know, if it is really true, what are the ...
10
votes
5answers
879 views
How to code in a more functional style in Java?
I code Java for at least 5 years now and I really appreciate how the language works. When looking at new JVM languages (e.g. Scala, Clojure) there is a trend to more functional ways to code and this ...
7
votes
3answers
167 views
Devising test of Haskell's value/reference semantics
In imperative languages, it is trivial to devise a programming test of language's use of "value semantics" or "reference semantics". One could do the following and check the value of a (where Vertex ...
4
votes
5answers
339 views
Java memory management (thunks/lazyness)
If I want to create an infinite list of integers in Java like so:
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i = 0;;i++){
list.add(i);
}
I run out of memory. My ...
1
vote
2answers
147 views
Sorting : Useful for more than just viewing data?
Context
I'm currently working on a personal project involving functional reactive JavaScript, and I've come up with an odd question. Note that this question is not JavaScript specific, but that is ...
3
votes
1answer
257 views
Is Clojure a 3GL or a 4GL?
A bit of background (in case I'm mistaken)...
I think I understand that (it's an oversimplification):
manually entering codes into memory (or on a punchcard) is "first generation language"
using ...
10
votes
1answer
580 views
Reasons for removal of function types in Java 8
I have been trying to understand why the JDK 8 Lambda Expert Group (EG) decided not to include a new function type into the Java programming language.
Going over the mailing list I found a thread ...
4
votes
2answers
110 views
Determinism of functions using PRNG in Clojure and functional languages
I'm a bit surprised by a sentence found in the book "Clojure Programming" (1st [and only as I write this!?] edition), page 78:
It should be obvious that it's impossible to deterministically test a
...
31
votes
4answers
2k views
In functional programming, does having most of the data structures immutable require more memory usage?
In functional programming since almost all data structure are immutable, when the state has to change a new structure is created. Does this mean a lot more memory usage? I know the object oriented ...
2
votes
1answer
280 views
C++ Design: Functional Programming vs OOP
Design Question
Recently, I've been doing more and more FP in C++, mostly in the form of function templates and lambdas, and heavy overloading of a single function name. I really like FP for some ...
3
votes
1answer
123 views
Network computation
I'm pretty sure that someone has already thought about it and researched it extensively, but I'm having trouble finding any materials or even keywords to look for, for the idea that I was thinking ...
26
votes
2answers
871 views
Misconceptions about purely functional languages?
I often encounter the following statements / arguments:
Pure functional programming languages do not allow side effects (and are therefore of little use in practice because any useful program does ...
20
votes
6answers
1k views
Functional programming compared to OOP with classes
I have been interested in some of the concepts of functional programming lately. I have used OOP for some time now. I can see how I would build a fairly complex app in OOP. Each object would know how ...
9
votes
3answers
461 views
Performance: recursion vs. iteration in Javascript
I have read recently some articles (e.g. http://dailyjs.com/2012/09/14/functional-programming/) about the functional aspects of Javascript and the relationship between Scheme and Javascript (the ...
5
votes
3answers
822 views
Fastest Functional Language
I've recently been delving into functional programming especially Haskell and F#, the prior more so. After some googling around I could not find a benchmark comparison of the more prominent functional ...
1
vote
1answer
158 views
What does “polyadic” mean in the context of functional programming and type systems?
And how does it (or does not) correspond to "polymorphic"? Occasionally I see this notion like in: Implement and represent polyadic operations. I checked Wiktionary but it only gives a general ...
7
votes
3answers
369 views
Why can't we write nested shorthand functions in Clojure?
I tried to evaluate a Clojure expression with nested shorthand functions today, and it wouldn't let me.
The expression was:
(#(+ % (#(+ % (* % %)) %)) 5) ; sorry for the eye bleed
The output was:
...
6
votes
4answers
459 views
What's special about currying or partial application?
I've been reading articles on Functional programming everyday and been trying to apply some practices as much as possible. But I don't understand what is unique in currying or partial application.
...
2
votes
1answer
118 views
Does automatic returning affect performance?
There's a bunch of languages that automatically return the last value in a function (mostly functional) like Ruby, Haskell, Lisp, etc.
Does this feature (or what do you call it) affect the ...
3
votes
3answers
258 views
Is there a name for this functional programming construct/pattern?
I wrote a function and I'd like to find out if it is an implementation of some functional programming pattern or construct. I'd like to find out the name of this pattern or construct (if it exists)?
...
8
votes
5answers
343 views
Compute if a function is pure
As per Wikipedia:
In computer programming, a function may be described as pure if both these statements about the function hold:
The function always evaluates the same result value given the ...
3
votes
2answers
254 views
What's the benefit of the Nothing constructor in Haskell?
I'm new to Haskell and I'm not really sold on the Nothing constructor. It sounds like just another silent fail that's going to create headaches down the line. It seems much more useful to throw an ...
1
vote
0answers
157 views
Boost Phoenix or Haskell GHC generating C [closed]
I am working on an iOS app that does some number crunching in a variety of areas that would greatly benefit from a functional programming approach, though much of the rest of the application is ...
2
votes
2answers
302 views
Using foldr to append two lists together (Haskell)
I have been given the following question as part of a college assignment. Due to the module being very short, we are using only a subset of Haskell, without any of the syntactic sugar or idiomatic ...
6
votes
3answers
232 views
Functional Methods on Collections
I'm learning Scala and am a little bewildered by all the methods (higher-order functions) available on the collections. Which ones produce more results than the original collection, which ones ...
2
votes
2answers
139 views
design a model for a system of dependent variables
I'm dealing with a modeling system (financial) that has dozens of variables. Some of the variables are independent, and function as inputs to the system; most of them are calculated from other ...
15
votes
3answers
741 views
Does immutability entirely eliminate the need for locks in multi-processor programming?
Part 1
Clearly Immutability minimizes the need for locks in multi-processor programming, but does it eliminate that need, or are there instances where immutability alone is not enough? It seems to ...
5
votes
2answers
192 views
Can higher-order functions in FP be interpreted as some kind of dependency injection?
According to this article, in object-oriented programming / design dependency injection involves
a dependent consumer,
a declaration of a component's dependencies, defined as interface contracts,
an ...
3
votes
1answer
255 views
What is the difference between functional relational programming and functional programming?
After reading both this thread and the linked paper, I don't understand how FRP (functional relational programming) is different from (FP) functional programming.
Does FRP augment or replace FP? Can ...
5
votes
1answer
261 views
C++11 support for higher-order list functions
Most functional programming languages (e.g. Common Lisp, Scheme / Racket, Clojure, Haskell, Scala, Ocaml, SML) support some common higher-order functions on lists, such as map, filter, takeWhile, ...
2
votes
1answer
89 views
Guidelines for creating referentially transparent callables
In some cases, I want to use referentially transparent callables while coding in Python. My goals are to help with handling concurrency, memoization, unit testing, and verification of code ...
8
votes
5answers
359 views
What's the proper term for a function inverse to a constructor - to unwrap a value from a data type?
Edit: I'm rephrasing the question a bit. Apparently I caused some confusion because I didn't realize that the term destructor is used in OOP for something quite different - it's a function invoked ...
2
votes
3answers
173 views
Internal Mutation of Persistent Data Structures
To clarify, when I mean use the terms persistent and immutable on a data structure, I mean that:
The state of the data structure remains unchanged for its lifetime. It always holds the same data, ...
9
votes
8answers
1k views
Why isn't functional language syntax more close to human language?
I'm interested in functional programming and decided to get head to head with Haskell. My head hurts... but I'll eventually get it...
I have one curiosity though, why is the syntax so cryptic (in lack ...
5
votes
5answers
463 views
When to use functional programming approach and when not? (in Java)
let's assume I have a task to create a Set of class names. To remove duplication of .getName() method calls for each class, I used org.apache.commons.collections.CollectionUtils and ...
6
votes
1answer
307 views
Why does Scala require functions to have explicit return type?
I recently began learning to program in Scala, and it's been fun so far. I really like the ability to declare functions within another function which just seems to intuitive thing to do.
One pet ...
10
votes
2answers
306 views
Are there any specific workflows or design patterns that are commonly used to create large functional programming applications?
I have been exploring Clojure for a while now, although I haven't used it on any nontrivial projects. Basically, I have just been getting comfortable with the syntax and some of the idioms. Coming ...
11
votes
2answers
242 views
FP for simulation and modelling
I'm about to start a simulation/modelling project. I already know that OOP is used for this kind of projects. However, studying Haskell made me consider using the FP paradigm for modelling a system of ...
4
votes
3answers
373 views
From Imperative to Functional Programming
As an Electronic Engineer, my programming experience started with Assembly and continue with PL/M, C, C++, Delphi, Java, C# among others (imperative programming is in my blood).
I'm interested in ...