functional-programming

Learning Functional Programming?

I've recently been dabbling in functional programming with languages like Lua, Scheme and most notably F# and there are a lot of resources to learn these languages. However, the resources that I've found and have been using essentially teach only the syntax of these languages. While that's important, I can do this in a day or two. I j...

Warnings about unused variables in Erlang

I recently started Erlang, and I notice I constantly get "Warning: variable X is unused" while compiling. For example, take the following function, which finds the maximum element in a list: max([Head|Tail]) -> max(Head,Tail). max(Element,[Head | Tail]) when Element < Head -> max(Head,Tail); max(Element,[Head...

What is the usefulness of project1st<Arg1, Arg2> in the STL?

I was browsing the SGI STL documentation and ran into project1st<Arg1, Arg2>. I understand its definition, but I am having a hard time imagining a practical usage. Have you ever used project1st or can you imagine a scenario? ...

What are all the way that you try to make your code functional like?

so that you can make your program concurrent easily in the future. ...

Generating permutations lazily

I'm looking for an algorithm to generate permutations of a set in such a way that I could make a lazy list of them in Clojure. i.e. I'd like to iterate over a list of permutations where each permutation is not calculated until I request it, and all of the permutations don't have to be stored in memory at once. Alternatively I'm looking...

Functional programming: state vs. reassignment

I need help getting my head around the difference between my current OOP notion of state, and the way it would be done in a functional language like Haskell or Clojure. To use a hackneyed example, let's say we're dealing with simplified bank account objects/structs/whatever. In an OOP language, I'd have some class holding a reference ...

Clojure vs Haskell for web applications?

I want to learn a functional language that will be good for building web applications in the future. I am choosing between Clojure and Haskell. Which one is a better choice for my purpose? ...

Explanation of “tying the knot”

In reading Haskell-related stuff I sometimes come across the expression “tying the knot”, I think I understand what it does, but not how. So, are there any good, basic, and simple to understand explanations of this concept? ...

Functional programming: immutability etc.

I recently asked a question about functional programming, and received (good!) answers that prompted more questions (as seems to be the case with learning, sometimes). Here are a couple examples: One answer made reference to an advantage of immutable data structures: each thread can have its own copy. Now, to me, this sounds rather lik...

How long before the line of business app in F# becomes the norm?

With the recent news about F# being included with Visual Studio 2010, I got to thinking ... how soon before I see functional programming take hold in the usual "line of business app" space? ...

What's the difference between a parameter passed by reference vs. passed by value?

I need help. what is difference between a parameter passed by reference, and a parameter passed by value? Could you give me some examples please? ...

What are some good Erlang Primers/Tutorials for beginners?

What are some good links for diving into Erlang and functional programming in general? ...

What are some good Haskell Primers/Tutorials for beginners?

What are some good links for diving into Haskell and functional programming in general? ...

What is the Zipper data structure and should I be using it?

The question is simple: I cannot understand the Zipper data structure. My question is related to its uses with a Tree. I want to understand how can I change the tree node using zipper. And how not to copy the whole tree (or the most part of it). Please, clarify if I'm wrong with zipper. Maybe it cannot help with the tree update? Or, m...

Non-numerical use cases for functional programming ?

I just finished reading a book on scala. What strikes me is that every single example in the whole book was numerical in some form or another. Like a lot of programmers, the only math I use is from discrete and combinatorial mathematics, and usually that's not math I program in an explicit way. I'm really missing some compelling example...

Implications of foldr vs. foldl (or foldl')

Firstly, Real World Haskell, which I am reading, says to never use foldl instead of foldl'. So I trust it. But I'm hazy on when to use foldr vs. foldl'. Though I can see the structure of how they work differently laid out in front of me, I'm too stupid to understand when "which is better." I guess it seems to me like it shouldn't real...

Modify bound variables of a closure in Python

Is there any way to modify the bound value of one of the variables inside a closure? Look at the example to understand it better. def foo(): var_a = 2 var_b = 3 def _closure(x): return var_a + var_b + x return _closure localClosure = foo() # Local closure is now "return 2 + 3 + x" a = localClosure(1) # 2 + 3 + 1 == 6 # DO SO...

Any real world experience debugging a production functional program?

I'm interested in what tools and methods are used for diagnosing flaws in large scale functional programs. What tools are useful? My current understanding is that 'printf' debugging (e.g. add logging and redeploy) is what is typically used. If you've done debugging of a functional system what was different about it then debugging a ...

Why is C# a functional programmming language?

It has been said that C# can be regarded as a functional programming language, even though it is widely recognized as a OO programming language. So, what feature set makes C# a functional programming language? I can only think of: delegates (even without anonymous methods and lambda expressions) closures Anything else? ...

F# on mono in leopard. Seq.cast error.

I came across this answered question, but I can't seem to compile the code. I'm getting the following error on Seq.cast: error FS0039: The value, constructor, namespace or type 'cast' is not defined. I'm using Mono 2.0.1_1 and F# 1.9.4.19 on leopard. Is there something funky with f# when running under mono? ...