Tagged Questions
5
votes
6answers
555 views
Are closures considered impure functional style?
I have a few related questions on closures:
Are closures considered impure in functional programming?
It seems one can generally avoid closures by passing values directly to a function. Therefore ...
4
votes
1answer
203 views
Passing a Scala function to a Java 8 method
The following Scala code works and can be passed to a Java method expecting a function. Is there a cleaner way to do this? Here's my first pass:
val plusOne = new ...
2
votes
6answers
763 views
An alternative to an array of functions?
I'm programming an app (php) which requires a very long list of similar yet different functions, which are being called by a set of keys:
$functions = [
"do this" => function() {
// ...
3
votes
3answers
429 views
Good Procedure or Function Design
This is in reference to the question posted here. As I would judge it, the question there should be closed simply because it seems to ask why the Borland developers made one thing a function and ...
8
votes
2answers
775 views
What is an example of a continuation not implemented as a procedure?
An interesting discussion about the distinction between callbacks and continuations over on SO has prompted this question. By definition, a continuation is an abstract representation of the logic ...
44
votes
4answers
2k views
How do functional languages handle random numbers?
What I mean about that is that in nearly every tutorial I've read about functional languages, is that one of the great things about functions, is that if you call a function with the same parameters ...
2
votes
4answers
309 views
How do you decide what code to put into a function?
I started out with a script that was a few hundred lines. Later, I realized I wanted another script that would require much of the same code. I decided to wrap certain areas of the original script ...
0
votes
1answer
146 views
LOOP program only need inc and zero
I have 4 different commands in LOOP programming language:
y=Zero()
y=Val(x)=copy x and put it in register y
y=Inc(x)=x+1
y=Dec(x)=x-1
Finally I also have
loop n times {
...
...
2
votes
1answer
151 views
LOOP-computable functions
I was just reading a chapter about LOOP-computable functions and I have the following question: Is it possible to numerate every LOOP program with an algorithm?
Formally: Is it possible to have a ...
9
votes
3answers
938 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:
...
2
votes
1answer
142 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 ...
6
votes
3answers
454 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 ...
11
votes
5answers
307 views
Convert list of 24-hour-precipitation values into total-by-hour
Let's say I have a list of precipitation values by hour, each showing how much rain happened in the prior 24 hours, ordered by date. For example:
{
'2012-05-24 12:00': 0.5, // .5" of rain from ...
6
votes
4answers
1k views
What is the name for a NON-self-calling function?
I have a collection of normal functions and self-calling functions within a javascript file. In my comments i want to say something along the lines of "This script can contain both self-calling and ...