I'm intrigued that Python has some functional constructions in the language.
Paul Rubin
http
Sat May 9 15:08:49 EDT 2009
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> I think your point is wrong. Without syntax, there can be no written
> communication. In Haskell, f.g is not the same as f+g -- the difference
> is one of syntax.
In Haskell, (+) and (.) are both functions. (+) takes two numbers as
arguments and returns their sum. (.) takes two functions as arguments
and returns a new function which composes f and g. 2 + 3 is the same
as (+) 2 3. f . g is the same as (.) f g. The infix notations
are considered syntax sugar. The parentheses around (+) and (.)
are so the compiler doesn't get lexically confused, but you could say
add = (+)
compose = (.)
a = add 2 3
b = compose square cube
c = b 2
now "print a" will print 5, and "print c" would print 64 (which is 2**6).
(There aren't actually builtins square and cube, but pretend there are).
So it's really true you can get rid of almost all Haskell expression
syntax. There's actually a preprocessor called Liskell that lets you
write Haskell as Lisp-like S-expressions, which is handy if you want
to use a macro processor on it.
More information about the Python-list
mailing list