in reply to When would you use functional programming?
A long time ago I was using the computer algebra system Mathematica (Wolfram Research, ltd.). It has it's own programming language which is quite elegant. It is a functional language at heart, but with an imperative layer on top of it. Moreover, since it's a CAS, one can use logic programming techniques as well. Unfortunately, it lacked an OO layer.
It was very nice to work with since it allowed to mix and match programming paradigms as needed. One could write a function in functional style, imperative style or a mixture of both without being hampered by the programming language.
In this sense it was a very good example of "there's more than one way to do it" which I appreciate very much in Perl.
Perl has its functional components such as map, grep and closures. List;:Util also helps.
I really appreciate a language in which it is possible to use the style most appropriate to the problem, rather than having to wrestle to get matters done. Perl does a reasonable job at this, but still leaves a number of things to be desired.
As an aside, to illustrate the elegance of functional languages, consider the quicksort in Haskell.
qsort [] = [] qsort (x:xs) = qsort elts_lt_x ++ [x] ++ qsort elts_greq_x where elts_lt_x = [y | y <- xs, y < x] elts_greq_x = [y | y <- xs, y
Just my point of view, -gjb-
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: When would you use functional programming?
by Dominus (Parson) on Oct 18, 2002 at 17:15 UTC |