On 2009/03/13, at 11:29, Andrew Stacey wrote:
Afterwards, one student asked about how this related to functions as used in computer programming. It seemed from what he said that he had some understanding of the formal relationship between functions in mathematics and functions in computer programs - beyond them having the same name. He said that a function that takes no input is known as a "constant function" and so wasn't sure how to fit the two notions together.
A constant function in Haskell, as in Maths, has 1 as a domain. The (isomorphism class of the) singleton set is written as (); so, for example, the function always returning integer 5 is declared as five :: () -> Int and defined by five () = 5 (notice notation () is used to denote both set 1 and its (unique) element) Your student is probably confusing notation () with the empty set. The notation may be a bit unfortunate as () may suggest "no input" ... but, of course functions, in functional programming are just functions. Luis --------------------------------------- Luis S. Barbosa www.di.uminho.pt/~lsb