functional-programming

Is Javascript a Functional Programming Language?

Just because functions are first class objects, there are closures, and higher order functions, does Javascript deserve to be called a Functional Programming language? The main thing I think it lacks is Pure Functions, and it doesn't 'feel' like other functional languages, like lisp (although thats not really a good reason for it not to...

Algebraic data types outside of functional languages?

Mostly out of curiosity: Which languages that are not solely functional (I'm also interested in multi-paradigm languages - I know that Ocaml and F# are ML dialects with OO added, so they inherit the algebraic data types from ML) have algebraic data types (or something similar) and pattern matching? They can be kind-of emulated using enu...

Machine model for functional programming

I've read somewhere that the current machine model is not quite fit for functional programming. So what is the limitations of the current machine model? Has a more suitable machine model been developed? ...

Lazy "n choose k" in OCaml

Hi guys, As part of a bigger problem of enumerating a set, I need to write an OCaml function 'choose' which takes a list and outputs as the list of all possible sequences of size k made up of elements of that list (without repeating sequences which can be obtained from each other by permutation). The order they are put in the end list i...

Pluggable vector processing units in Clojure

I'm developing some simulation software in Clojure that will need to process lots of vector data (basically originating as offsets into arrays of Java floats, length typically in 10-10000 range). Large numbers of these vectors will need to go through various processing steps - e.g. normalising the vectors, concatenating together two stre...

What should I use Clojure's finger trees for?

Clojure's new contrib library group has a finger tree library. What are the use cases for finger trees in clojure? When should finger trees be used instead of one of clojure's other peristent data strucures: vectors, sets, maps, persistentqueues, etc. The Joy of Clojure mentions that Finger trees can be used for indexed collections wh...

What is the best language for functional programming ?

I want to learn some powerfull language for functional programming and AI. I have experience with Lisp programming. I also know C# and Java, work on Linux and Windows equal. My question is: F# or Scala or something else ? ...

Is this a sensible monad for mutable state in Clojure?

I've been experimenting with monads in Clojure and came up with the following code, where a monadic value/state pair is represented by a mutable Clojure deftype object. Since the object is mutable, an advantage would seem to be that you can write monadic code without needing to construct new result objects all the time. However, I'm pr...

Parsing Expression Tree with BinaryExpression AND

hello... I'm just in the early process of learning about expression trees. As far as I understand, the good thing about them is that they can be parsed when they are used as parameters, so for instance: Foo.Bar(x => x.Process == "On" && x.Name == "Goofy") But how can I parse the expression when there is AND inside? Maybe I've misund...

How can I reorder these F# functions to make sense?

I thought I'd be getting along alright with F# since I'm decent at Haskell, but I feel like I'm being stumped by dead simple issues. I have some parsing code for a simple JSON parser, like this: let rec parseObject tokens = function | '"' :: cs -> parseString tokens cs | ':' :: cs -> parseValue tokens cs | '}' :: cs -> tokens, cs ....

In C# is it a good practice to use recursive functions in algorithms?

In many functional languages using a recursion is considered to be a good practice. I think it is good because of the way compiler optimizes functional language's code. But is it a good practice to use recursion in C#, when creating an algorithm? Is it right to say in regards to C#, that recursive algorithms will result in your stack g...

Best explanation for Languages without Null

Every so often when programmers are bitching about null errors/exceptions someone asks what we do without null. I myself have some basic idea of the coolness of option types but I don't have the knowledge or languages skill to best express it. It would be useful if someone could point to or write an GREAT explanation of The undesirab...

Guava Function<> with void return value?

Does Googe Guava for Java have a Function inner class with a void return value, like C#'s action? I'm tired of making a bunch of Function<Float, Integer> with meaningless return values. ...

Should I read the first or second edition of "Introduction to Functional Programming" by Bird & Wadler?

I've heard it's better to read the first edition of "Introduction to Functional Programming" by Bird & Wadler than the second edition. The first edition uses Miranda, and the second edition uses Haskell. Is this a common recommendation? My goal is to get serious about functional programming. Thoroughly knowing the concepts of functio...

Is FC++ used by any open source projects?

The FC++ library provides an interesting approach to supporting functional programming concepts in C++. A short example from the FAQ: take (5, map (odd, enumFrom(1))) FC++ seems to take a lot of inspiration from Haskell, to the extent of reusing many function names from the Haskell prelude. I've seen a recent article about it, and i...

Are the "Iron" languages ready for prime time?

Is it okay to start using Iron Ruby and Iron Python in production systems? Also, are there any additional requirements for hosting them? And, for the bonus points, given that F# is a functional programming language in the same way that Python is, is there any advantage to using one over the other within the .NET framework? ...

If using Functional Oriented Programming does the "impedance mismatch" go away?

I see a lot of work at the moment on Entity Modelling in Code and interest in functional Programming. After some years working in Object Oriented Systems I have time and time again come up against the "Impedance Mismatch". Since Transact SQL implements some FOP with datasets being described as Sets in a declarative way, does the "imped...

How to sort the list by its accountID using quick sort in Haskell.

Im a student who is really new to functional programming. Im working on a banking application where the data has been already defined as, type Accountno = Int data Accounttype = Saving | Current | FixedDeposit deriving (Show,Read) type Accountamount = Int type Name = String type Account = (Accountno, Name, Accounttype, Accountamount)...

SML - LOST! help please...

In a EIK Bank should I make now an account called Nice Item, all operations seem like a Basic Account, except those payments, which works as follows: At each accrual added 4% (rounded down) of the balance immediately after the last payments, provided that the period remains unclaimed in the account. Has closed the account, attributed to ...

Howto move from object based language to server side Node.js Javascript for big projects?

Hi there, I've decided to get used to using Javascript as my server sided (I'm using Node.js) language to setup a webserver, create server deamons and a lot more. This is a rather big project, which means that I have to get used to the language and get myself an optimal setup before actually starting to avoid overhead and unneeded hassl...