functional-programming

What is the scope of a function in Javascript/ECMAScript?

Hello Javascript experts Today I had a discussion with a colleague about nested functions in Javascript: function a() { function b() { alert('boo') } var c = 'Bound to local call object.' d = 'Bound to global object.' } In this example, trials point out that b is not reachable outside the body of a, much like c is. ...

Pattern matching of lists in Python

I want to do some pattern matching on lists in Python. For example, in Haskell, I can do something like the following: fun (head : rest) = ... So when I pass in a list, head will be the first element, and rest will be the trailing elements. Likewise, in Python, I can automatically unpack tuples: (var1, var2) = func_that_returns_a_tu...

Which language would you use for the self-study of SICP?

I've caught the bug to learn functional programming for real. So my next self-study project is to work through the Structure and Interpretation of Computer Programs. Unfortunately, I've never learned Lisp, as I was not a CS major in college. While SICP does not emphasize the tools for programming, doing the exercises entails picking a ...

Logical negation operator in F#? (!-equivalent)

What is the equivalent to the C# "!" operator in F#? Thanks, Jacob ...

Function point to kloc ratio as a software metric... the "Name That Tune" metric?

What do you think of using a metric of function point to lines of code as a metric? It makes me think of the old game show "Name That Tune". "I can name that tune in three notes!" I can write that functionality in 0.1 klocs! Is this useful? It would certainly seem to promote library usage, but is that what you want? ...

Is anyone using D in commercial applications?

Ok, this is a little open ended, but I think D could do with a bit of promotion. Personally I think D is a superb implementation language - but it's not mainstream enough yet for many people to take it seriously. Since it's not commerically backed, the only way to change that is through community effort and visibility. So I'd really li...

Functional Programming: Best Platform/Environment

I have been researching and playing with functional programming lately, solely to broaden my thinking about programming, because I find thinking "functionally" difficult. I have downloaded Glasgow Haskell and experimented with that. What I am wondering is, what is the best platform for Windows to experiment with FP? I would prefer a J...

When to use closure?

I have seen samples of closure from - http://stackoverflow.com/questions/36636/what-is-a-closure Can anyone provide simple example of when to use closure? Specifically, scenarios in which closure makes sense? Lets assume that the language doesn't have closure support, how would one still achieve similar thing? Not to offend anyone, p...

Immutable object pattern in C# - what do you think?

I have over the course of a few projects developed a pattern for creating immutable (readonly) objects and immutable object graphs. Immutable objects carry the benefit of being 100% thread safe and can therefore be reused across threads. In my work I very often use this pattern in Web applications for configuration settings and other obj...

Why is lazy evaluation useful?

I have long been wondering why lazy evaluation is useful. I have yet to have anyone explain to me in a way that makes sense; mostly it ends up boiling down to "trust me". Note: I do not mean memoization. ...

Functional-style Updates

This may be an oxymoron, but how would one update a data entity in the functional programming style? From all I've read, functional-style programming uses transformations to return an output on immutable entities. The only thing I can think of would be to completely replace the original entity, but that seems almost the same as a classic...

F# help @ the newbie level

Suppose I have some code: let listB = [ 1; 2; 3 ] Using Lisp notation, how do I do a car and cadr against this list? I know cons is ::. Or in Scheme, first and rest? Thanks! :-) ...

An amnesia patient's "first" functional language? (I really like Clojure...)

I was recently diagnosed with a cascading dissociative disorder that causes retrograde amnesia in addition to an existing case of possible anterograde amnesia. Many people have tried to remind me of how great a programmer I was before -- Right now I get the concepts and the idioms, but I want to teach myself whether I know or not. I thin...

Is functional programming the next step towards natural-language programming?

This is my very first question so I am a bit nervous about it because I am not sure whether I get the meaning across well enough. Anyhow, here we go.... Whenever new milestones in programming have been reached it seems they always have had one goal in common: to make it easier for programmers, well, to program. Machine language, opcode...

Is there anything like a functional model?

In Object Oriented Paradigm, I would create an object/conceptual model before I start implementing it using OO language. Is there anything parallel to object model in functional programming. Is it called functional model? or we create the same conceptual model in both the paradigm before implementing it in one of the language.. Are th...

Fast element lookup for a functional language(Haskell)

Say we are traversing a graph and want to quickly determine if a node has been seen before or not. We have a few set preconditions. Nodes have been marked with integers values 1..N Graph is implemented with nodes having an adjacency list Every integer value from 1..N occurs in the graph, which is of size N Any ideas for doing this in...

Is there a fast language that supports portable continuations?

I'm looking for a fast language (ie. a language that can be compiled natively to achieve performance not more than 3 or 4 times slower than C), which supports portable continuations. By this I mean a continuation that can be serialized on one computer, and deserialized on another. I know that SISC can do this (a Scheme implementation i...

New to functional programming

...

Is functional programming relevant to web development?

I've been seeing so much recently about functional programming and Clojure looks particularly interesting. While I 'understand' the basic description of what it is, I can't figure out how I would use it on a day to day basis as a web developer, if I can at all. A lot of what I have read focuses on the maths side of functional programming...

C++: Using operator of two intrinsic types as a function object

I have a vector-like class that contains an array of objects of type "T", and I want to implement 4 arithmetic operators, which will apply the operation on each item: // Constructors and other functions are omitted for brevity. template<class T, unsigned int D> class Vector { public: // Add a value to each item: naive implementatio...