On Nov 12, 2009, at 21:15 , Casey Hawthorne wrote:
Why in a pattern match likescore (1 3) = 7 can I not have sizeMax = 3 score (1 sizeMax) = 7
Because it's a pattern, and when you introduce a symbol you are inviting the pattern match to bind what it matched to that name for use within the function. (Ordinary arguments are a trivial case of this.)
Or, by example: > score (1 sizeMax) = (expression using sizeMax) The normal way to do what you want is guards:> score (1 x) | x == sizeMax = 7 -- you can pronounce the "|" as "such that"
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe