functional-programming

What features make the functional language better for parallel programming?

The functional programming provides stateless way of programming that enables the user free of side effect. declarative way of programming that enables the user describe the problem sets that the computer should solve, not the way of the problems are solved. Combining those features, users can program in higher level that can be swa...

Truly declarative language?

Hi all, Does anyone know of a truly declarative language? The behaviour I'm looking for is kind of what Excel does, where I can define variables and formulas, and have the formula's result change when the input changes (without having set the answer again myself) The behaviour I'm looking for is best shown with this pseudo code: X = ...

How do I implement graphs and graph algorithms in a functional programming language?

Basically, I know how to create graph data structures and use Dijkstra's algorithm in programming languages where side effects are allowed. Typically, graph algorithms use a structure to mark certain nodes as 'visited', but this has side effects, which I'm trying to avoid. I can think of one way to implement this in a functional langu...

in C++, what is the best method to feed the O/P of one function to another function?

Under these conditions, The o/p of the first program is an large array of either integers, doubles or strings. Best method means the fastest on x86 architecture. o/p means output. Sorry for being unclear. ...

Can you dynamically combine multiple conditional functions into one in Python?

I'm curious if it's possible to take several conditional functions and create one function that checks them all (e.g. the way a generator takes a procedure for iterating through a series and creates an iterator). The basic usage case would be when you have a large number of conditional parameters (e.g. "max_a", "min_a", "max_b", "min_...

Right rotate of tree in Haskell: how is it work?

I don't know haskell syntax, but I know some FP concepts (like algebraic data types, pattern matching, higher-order functions ect). Can someone explain please, what does this code mean: data Tree ? = Leaf ? | Fork ? (Tree ?) (Tree ?) rotateR tree = case tree of Fork q (Fork p a b) c -> Fork p a (Fork q b c) As I understand, first ...

Functional languages targeting the LLVM

Are there any languages that target the LLVM that: Are statically typed Use type inference Are functional (i.e. lambda expressions, closures, list primitives, list comprehensions, etc.) Have first class object-oriented features (inheritance, polymorphism, mixins, etc.) Have a sophisticated type system (generics, covariance and contrava...

List filtering: list comprehension vs. lambda + filter

I happened to find myself having a basic filtering need: I have a list and I have to filter it by an attribute of the items. My code looked like this: my_list = [i for i in my_list if i.attribute == value] But then i thought, wouldn't it be better to write it like this? filter(lambda x: x.attribute == value, my_list) It's more rea...

Is there a programming language that performs currying when named parameters are omitted?

Many functional programming languages have support for curried parameters. To support currying functions the parameters to the function are essentially a tuple where the last parameter can be omitted making a new function requiring a smaller tuple. I'm thinking of designing a language that always uses records (aka named parameters) for ...

Zipping with padding in Haskell

A couple of times I've found myself wanting a zip in Haskell that adds padding to the shorter list instead of truncating the longer one. This is easy enough to write. (Monoid works for me here, but you could also just pass in the elements that you want to use for padding.) zipPad :: (Monoid a, Monoid b) => [a] -> [b] -> [(a, b)] zipPad ...

Explicit method tables in C# instead of OO - good? bad?

Hi! I hope the title doesn't sound too subjective; I absolutely do not mean to start a debate on OO in general. I'd merely like to discuss the basic pros and cons for different ways of solving the following sort of problem. Let's take this minimal example: you want to express an abstract datatype T with functions that may take T as inp...

Datatype-generic programming libraries for Scala

I'm looking for a Scala library allowing for datatype-generic programming (like Scrap Your Boilerplate, for example). A list of libraries with appropriate links and short descriptions for each one would be a perfect answer. ...

Learning Haskell maps, folds, loops and recursion

I've only just dipped my toe in the world of Haskell as part of my journey of programming enlightenment (moving on from, procedural to OOP to concurrent to now functional). I've been trying an online Haskell Evaluator. However I'm now stuck on a problem: Create a simple function that gives the total sum of an array of numbers. In a ...

Does Scheme work with Microsoft COM?

I'm new to Scheme -- the functional programming language and I like it a lot for its first-class/higher-order functions. However, my data comes from a COM source with an object-oriented API. I know Scheme and COM belong to different programming paradigms, but I'm wondering if there is any interface or a way for Scheme to connect to a C...

Is the FoldLeft function available in R?

Hi, I would like to know if there is an implementation of the foldLeft function (and foldRight?) in R. The language is supposed to be "rather" functional oriented and hence I think there should be something like this, but I could not find it in the documentation. To me, foldLeft function applies on a list and has the following signatu...

How do functional language gui bindings work?

Do they typically use non functional aspects of the language (including mutable variables). Are there other strategies? Could you describe them? ...

What's the status of multicore programming in Haskell?

What's the status of multicore programming in Haskell? What projects, tools, and libraries are available now? What experience reports have there been? ...

how does one _model_ data from relational databases in clojure ?

I have asked this question on twitter as well the #clojure IRC channel, yet got no responses. There have been several articles about Clojure-for-Ruby-programmers, Clojure-for-lisp-programmers.. but what is the missing part is Clojure for ActiveRecord programmers . There have been articles about interacting with MongoDB, Redis, etc. - ...

Design patterns for functional-oo hybrid languages?

Is there already any collection of best practices for languages like Scala? I've found a work on design patterns for functional languages here. There's GoF design patterns for oo languages. But are there any patterns for functional-oo hybrids? All I've seen is this list. Does anyone know any more? ...

F# and ADO.NET - idiomatic F#

I'm just starting to learn F#. I wrote this F#/ADO.NET code last night. In what ways would you improve the syntax - make it feel like idiomatic F#? let cn = new OleDbConnection(cnstr) let sql = "SELECT * FROM People" let da = new OleDbDataAdapter(new OleDbCommand(sql, cn)) let ds = new DataSet() cn.Open() let i =...