functional-programming

Do concepts like Map and Reduce apply to all Functional Programming Languages?

I have just started delving into the world of functional programming. A lot of OOP (Object Oriented Programming) concepts such as inheritance and polymorphism apply to most modern OO languages like C#, Java and VB.NET. But how about concepts such as Map, Reduce, Tuples and Sets, do they apply to all FP (Functional Programming) language...

View Reduction Steps in Haskell

I was wondering if there is anyway to view the reduction steps in haskell, i.e trace the recursive function calls made, for e.g chez scheme provides us with trace-lambda, is there an equivalent form in Haskell, and how to use it? Thanks, Shiv ...

Learning Scala or Haskell

I'm considering dipping my toe in the functional programming world, and wondering if it would be better to start with Scala or Haskell. I'm coming at this primarily as a Python programmer. My only real functional programming experience with functional programming is using Scheme in an intro comp-sci class over a decade ago. Some of th...

How does one detect mutation in a C# function?

I've been reading articles on how to program in a functional (i.e F#) style in C#, for example, foregoing loops for recursion and always returning a copy of a value/object instead of returning the same variable with a new state. For example, what sort of code inspection things should I watch out for? Is there any way to tell if a metho...

The power of functional programming?

Functional programming is growing quickly. A lot of advices "How to prepare for the future" I've read contain "Learn a functional programming language". I am new to functional programming. What is its true power? Is it replacing OOP? What fields of programming that functional programming is most powerful? What functional programming la...

Haskell or Standard ML for beginners?

I'm going to be teaching a lower-division course in discrete structures. I have selected the text book Discrete Structures, Logic, and Computability in part because it contains examples and concepts that are conducive to implementation with a functional programming language. (I also think it's a good textbook.) I want an easy-to-underst...

Is there a way to check whether function output is assigned to a variable in Python?

In Python, I'd like to write a function that would pretty-print its results to the console if called by itself (mostly for use interactively or for debugging). For the purpose of this question, let's say it checks the status of something. If I call just check_status() I would like to see something like: Pretty printer status check 0....

Implementing ESB (Enterprise Service Bus) in a functional language

I am hoping that an architecture question is reasonable on Stackoverflow, so I am asking this here. I have been trying to see where a functional language would be useful outside of math-oriented problems, and it dawned on me that an ESB (Enterprise Service Bus) would be perfect for a FP language, as there isn't anything shared between r...

Loops in SML/NJ

I'm very new to SNL/NJ and was wondering how I could accomplish the following: foo(stuff,counter) { while(counter > 0) { bar(stuff); counter-1; } return; } Something like this, but how do I decrement?: foo(stuff,counter) = while counter > 0 do bar(stuff) ??? // how do I decrement counter here? ...

functional languages (erlang, f#, haskell, scala)

Hi, 1) Are functional languages suited for web applications development ? 2) Are functional languages suited for business/erp/crm type of applications ? ...

Writing Extension methods with Action / Func / Delegates / Lambda in VB and C#

hey guys. Firstly I can't get my head around the functional / Lambda aspects of .NET 3.5. I use these features everyday in LINQ, but my problem is understanding the implementation, and what they really mean (Lambda? System.Func? etc etc) With this in mind, how would the following be achieved: As an example, I'd like to have an Extensi...

Does Ruby perform Tail Call Optimization?

Functional languages lead to use of recursion to solve a lot of problems, and therefore many of them perform Tail Call Optimization (TCO). TCO causes calls to a function from another function (or itself, in which case this feature is also known as Tail Recursion Elimination, which is a subset of TCO), as the last step of that function, t...

Functional programming - standard symbols, diagrams, etc

I have a problem, which I believe to be best solved through a functional style of programming. Coming from a very imperative background, I am used to program design involving class diagrams/descriptions, communication diagrams, state diagrams etc. These diagrams however, all imply, or are used to describe, the state of a system and the ...

Extract single element from list in F#

I want to extract a single item from a sequence in F#, or give an error if there is none or more than one. What is the best way to do this? I currently have let element = data |> (Seq.filter (function | RawXml.Property (x) -> false | _ -> true)) |> List.of_seq |> (function head :: [] -> head | head...

Where do I get more information on Homoiconicity?

I have been experimenting with functional programming and I still dont understand the concept. Do you guys know any good books or tutorials or examples that discuss this concept? Or if you could show small snippets about its usage, that would be great. ...

Can 2 or more equations defining a function in Haskell share the same where / let block?

Can 2 or more equations defining a function in Haskell share the same where / let block? Let me present a contrived example to illustrate the question. First, consider the following code as a starting point: someFunction v1 v2 v3 = difference ^ v3 where difference = v1 - v2 So far, so good. But then, imagine I need to deal...

Guidelines for applying DRY in Haskell function definitions

I have a question about whether or not a specific way of applying of the DRY principle is considered a good practice in Haskell.I'm going to present an example, and then ask whether the approach I'm taking is considered good Haskell style. In a nutshell, the question is this: when you have a long formula, and then you find yourself needi...

Functional: construct a list of integers 1..n

This is not homework. I'm learning Standard ML on my own. I know a bit of Scheme, too, so this question ought to be answerable in either language. My self-imposed assignment is to write a function that constructs a list of integers from 1 to n. For example, list(7) should return [1,2,3,4,5,6,7]. An O(n) solution would be ideal. It's ea...

What are the benifits of learning F#?

I hear so much hype about F#. What makes functional programming so great? Is it really worth leaning? ...

How to get F# working with Mono?

I can't seem to find a compiler/plugin for mono. Does one exist? ...