[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Functional programming (was Re: Default value in function parameters?)
- From: David Given <dg@...>
- Date: Thu, 21 Sep 2006 19:10:06 +0100
David Jones wrote:
[...]
> I'm not really a pattern man, but Lua is great for functional
> programming. You just have to build all the basic tools (map, curry,
> fold, apply, etc) yourself, but that's fine.
Lua doesn't have pattern matching, which is a key point in most
functional languages --- the classic Fibonacci algorithm using pattern
matching is:
fib 1 = 1
fib 2 = 1
fib n = fib (n-1) + fib (n-2)
It could hardly be clearer.
If you're going to try programming in a functional language and don't
mind a steep learning curve, I'd recommend Haskell, primarily because
it's a *very* functional language --- functions have no side effects.
With partially procedural languages like OCaml it's very tempting to use
procedural constructs simply because they're available. Haskell forces
you to think functionally simply in order to get stuff done.
(Haskell's a member of the same family of languages as OCaml, ML,
Miranda etc, so the syntax is very similar as the others. Oh, yeah ---
in the functional world ML has a reputation for only being useful for
writing ML compilers!)
--
+- David Given --McQ-+ "Is Eris true?" "Everthing is true." "Even false
| dg@cowlark.com | things?" "Even false things are true." "How can
| (dg@tao-group.com) | that be?" "I don't know, man. I didn't do it!"
+- www.cowlark.com --+ --- _Prinicipa Discordia_
Attachment:
signature.asc
Description: OpenPGP digital signature