At work we used to program our Python in a pretty standard OO way. Lately, a couple guys got on the functional bandwagon. And their code now contains lots more lambdas, maps and reduces. I understand that functional languages are good for concurrency but does programming Python functionally really help with concurrency? I am just try...
I've heard that the following features reduce debuggability (because they are anonymous and debuggers cannot trace it well)
Anonymous Classes
Inner Classes
Closures Blocks / Lambda functions
Is this true?
...
I have been dabbling with F# in Visual Studio 2010. I am a developer with more code/architecture design experience in object-oriented languages such as C# and Java.
To expand my skill set and help make better decisions I am trying different languages to do different things. In particular get the hang of coding "correctly" using func...
I would like to understand which is the difference between these two programming concepts. The first represents the absence of data type and at the latter the type exists but there is no information. Additionally, I recognize that Unit comes from functional programming theoretical foundation but I still cannot understand what is the usab...
I'm still a Scala noob, and this confuses me:
import java.util.regex._
object NumberMatcher {
def apply(x:String):Boolean = {
val pat = Pattern.compile("\\d+")
val matcher = pat.matcher(x)
return matcher.find
}
def unapply(x:String):Option[String] = {
val pat = Pattern.compile("\\d+")
val matcher = pat.matche...
I tried to create an unapply method to use in pattern matching, and I tried to make it return something different than Option, however, Eclipse shows that as an error. Is it a rule that unapply must return an Option[T] ?
EDIT: here's the code I'm trying to use. I switched the code from the previous section so that unapply returns a Bool...
I was spoiled by the excellence of "Programming Ruby" when I was in high school, and ever since I've always looked for a combined introduction & language reference book for every new language I attempt.
Note that it doesn't have to be a dead-tree book; any well-written, high-quality resource would be great, regardless of media. This ...
Hi there!
This is a relatively long post. F# has a matrix and vector type(in PowerPack not in the Core) now. This is great! Even Python's numerical computing ability is from the third part.
But the functions provided there is limited to the matrix and vector arithmetic, so to do inversion, decompositions etc. we still need to use anot...
There are many SO posts related to this, but I am asking this again with a different purpose
I am trying to understand why closures are important and useful. One of things that I've read in other SO posts related to this is that when you pass a variable to closure, the closure starts remembering this value from then onwards. Is this the...
I'm just starting up with F# and see how you can use currying to pre-load the 1st parameter to a function. But how would one do it with the 2nd, 3rd, or whatever other parameter? Would named parameters to make this easier? Are there any other functional languages that have named parameters or some other way to make currying indifferen...
I have been trying to wrap my head around functional programming for a while now? I have looked up lambda calculus, LISP, OCML, F# and even combinatorial logic but the main problem I have is how do you do things that require side effects like (interacting with a user, communicating with a remote service, or even handle simulating using ...
Could somebody explain what an "improper list" is?
Note: Thanks to all ! All you guys rock!
...
Let's assume this function:
def autoClosing(f: {def close();})(t: =>Unit) = {
t
f.close()
}
and this snippet:
val a = autoClosing(new X)(_)
a {
println("before close")
}
is it possible to curry the first part? Something like:
val a = autoClosing(_) { println("before close") }
so that I could send the objects on which cl...
Hi,
I have a question about which style is preferred: std::bind Vs lambda in C++0x. I know that they serve -somehow- different purposes but lets take an example of intersecting functionality.
Using lambda:
uniform_int<> distribution(1, 6);
mt19937 engine;
// lambda style
auto dice = [&]() { return distribution(engine); };
Using bind...
Hi!
Something like
let f x = log(x)
and later I can apply f to matrix, vector or a float.
I guess it is not possible since F# is strictly static typed. Any other patters to overcome this problem?
Thanks!
...
Haskell is a pure functional language, which means Haskell functions have no side affects. I/O is implemented using monads that represent chunks of I/O computation.
Is it possible to test the return value of Haskell I/O functions?
Let's say we have a simple 'hello world' program:
main :: IO ()
main = putStr "Hello world!"
Is it poss...
Had learned Haskell during a Functional Programming course in school. Had found Haskell a bit difficult to work with. Have now worked a lot on Python. Python is quite easy to work with.
Python does support some functional programming constructs.
Was thinking of revisiting Functional Programming. What would be a better language to code?...
Hi, a little rusty from my Scheme days, I'd like to take 2 lists: one of numbers and one of strings, and fold them together into a single string where each pair is written like "{(ushort)5, "bla bla bla"},\n". I have most of it, i'm just not sure how to write the Fold properly:
let splitter = [|","|]
let indexes =
indexStr.Split(spli...
I think JavaScript doesn't have anything like obj.first, but I was wondering if something like this can be achieved in any way:
var foobar = { aint: "foo", an: "bar", array: "foobar" };
var recursiveObjDump = function (obj, idx) {
if (idx == obj.last.index) return obj[idx];
else return obj[idx] + " " + recursiveObjDump(obj, obj[...
I'd like to know if there exists a spreadsheet application which uses an existing functional-programming language to define functions.
I've already heard about Resolver One which uses python, but I'm more interested in anything which uses a purely functional language like Haskell.
Thanks
...