http://www.perlmonks.org?node_id=369189


in reply to Re: RFC: A Perlesque Introduction to Haskell, Part One (draft)
in thread RFC: A Perlesque Introduction to Haskell, Part One (DRAFT)

Interesting comparison. True, in functional languages solutions tend to be in the form of an answer given a valid input - but this is the same as non-functional languages. Perl's
sub factorial { my ($i) = @_; return 1 if ( $i <= 0 ); return $i * factorial( $i-1 ); }
is barely different from the generic functional code of
factorial 0 : 1; factorial i : i * factorial( i - 1 );
Both are solutions to the question 'what is factorial(i).' So, really, I'd say that coding in general is about forming well-defined questions, writing those down on paper, and then composing answers in code.

Incidentally, I believe most functional languages have a full-fledged concept of state. Even Prolog, that bastion of 'tell us the rules, and we'll get you an answer' can be twiddled to spit out state at every recursion (otherwise debugging would be a royal pain). And it's worth mentioning that it's not uncommon to write a functional program based on a problem that's formed in state-machine terms, just because it's so easy to handle such problems.

But programs as 'composing answers' - I like it. Nice thought.