functional-programming

Functional programming in C with macro "Higher Order Function" generators

Pay attention carefully because this is a hell of a question ;-) I want to use template functions for generic collection actions (like search, foreach, etc.) in C while maintaining compiler static type checking. It is fairly straightforward while you're using simple callbacks like in this example: #define MAKE_FOREACH(TYPE)\ void forea...

Recursive lambdas in F#

Take this example code (ignore it being horribly inefficient for the moment) let listToString (lst:list<'a>) = ;;' prettify fix let rec inner (lst:list<'a>) buffer = ;;' prettify fix match List.length lst with | 0 -> buffer | _ -> inner (List.tl lst) (buffer + ((List.hd lst).ToString())) inner lst "" ...

Should I always give a return value to my function?

I write JavaScript code and I try to use its functional language nature. In other functional languages (or even in Ruby), if I don't explicitly set the return value of a function, it will return the value of the last evaluated expression. JavaScript does not follow this pattern. (To be precise, JavaScript always returns a value as well....

Are some Functional Programming languages syntactically geared for better performance?

I hear about the manifold increase in productivity, while using certain languages (RoR). I have also heard about some VMs being more optimal than others (GHC?). Yet others are trying to optimize their language of choice by improving the underlying architecture (Unladen Swallow) However, while reading a paper ("SSA is functional programm...

Could someone explain these Haskell functions to me?

I've dabbled with Haskell in the past, and recently got back into it seriously, and I'm reading real world haskell. Some of the examples they've shone, I've yet to understand. Such at this one: myLength [] = 0 myLength (x:xs) = 1 + myLength (xs) I don't see how this works, what is 1 really being added too? How is the recursion ret...

Python equivalent of maplist?

What's the best Python equivalent of Common Lisp's maplist function? From the maplist documentation: maplist is like mapcar except that function is applied to successive sublists of the lists. function is first applied to the lists themselves, and then to the cdr of each list, and then to the cdr of the cdr of each list,...

How difficult is it to learn F# for experienced C# 3.0 developers?

How difficult is it to learn F# for experienced C# 3.0 developers, and/or what would you say is the most difficult part of learning F#? ...

convert string list to int list in haskell

Hi, I've got a list of strings, is it possible to convert it to an list of ints? eg: ["1","2"] -> [1,2] THANKS, ...

What are zygo/meta/histo/para/futu/dyna/whatever-morphisms?

Is there a list of them with examples accessible to a person without extensive category theory knowledge? ...

Functional Development On The CLR

If this has already been asked and answered, please point me to the existing Q & A and I'll delete this question. I did look and didn't see this one answered. Are there mainly functional languages (like LISP, Scheme, Haskell and so forth) besides F# for the CLR platform? I say "mainly functional" because realize there are CLR language...

Basic F# questions: mutability, capitalization standards, functions vs. methods

Feel free to point me to other answers if these have already been asked! I'm just starting F# with the new release this month. I've got some background in both OO and functional languages (Haskell and Scheme, but not OCaml/ML). A couple of questions have arisen so far from reading through the little tutorial thing that comes with the F#...

What is a 'thunk', as used in Scheme or in general?

Hi all, I come across the word 'thunk' at a lot of places in code and documentation related to Scheme, and similar territories. I am guessing that it is a generic name for a procedure, which has a single formal argument. Is that correct? If yes, is there more to it? If no, please? For eg. in SRFI 18, in the 'Procedures' section. ...

What is the best Functional Programming Language for Experienced OO Developers?

I'm a very experienced Object Oriented developer. Which of the Functional Programming languages would be the best one for getting my feet wet? Keeping in mind: IDE Compiler Maturity Debugging Tools Which Functional Programming language would you recommend? ...

How would you approach this problem in F#? (high frequency sensor data)

Hello, I'm a mechanical engineering grad student and my adviser has just asked me to write a data visualization utility for one of our sensor projects. As it's summer and he wants me to have some fun with it, I thought this would be a great time to learn a language adept at scientific computing, so I went ahead and plowed right into F#....

Functional paragraphs

Sorry I don't quite get FP yet, I want to split a sequence of lines into a sequence of sequences of lines, assuming an empty line as paragraph division, I could do it in python like this: def get_paraghraps(lines): paragraphs = [] paragraph = [] for line in lines: if line == "": # I know it could also be "if line:" ...

Efficient heaps in purely functional languages

As an exercise in Haskell, I'm trying to implement heapsort. The heap is usually implemented as an array in imperative languages, but this would be hugely inefficient in purely functional languages. So I've looked at binary heaps, but everything I found so far describes them from an imperative viewpoint and the algorithms presented are h...

What is implicit recursion?

What is implicit recursion? How is it different from explicit recursion? ...

Which language in DrScheme for SICP?

Hi, I have been using the Module for SICP in DrScheme 4.2 but which language has the best support for SICP in DrScheme? Has anyone here tried this? Thanks. ...

Point-free style with objects/records in F#

I'm getting stymied by the way "dot notation" works with objects and records when trying to program in a point-free functional style (which I think is a great, concise way to use a functional language that curries by default). Is there an operator or function I'm missing that lets me do something like: (.) object method instead of objec...

How to write lambda methods in Objective-C ?

How to write lambda methods in Objective-C ? ...