
On Nov 12, 2009, at 21:15 , Casey Hawthorne wrote:
Why in a pattern match like
score (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] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH