[clean-list] Pattern matching

Dmitry Malenko maldim@gmx.net
Sat, 04 Jan 2003 10:30:05 +0200


Hi!

I'm new to Clean, so forgive if it is a silly question.

I have the following code:

module test

import StdEnv

s x     = 3*x
s [x]   = 2*x
s [x,y] = x*y

Start = s 4

When compile it I get warning: "[test.icl,5,s] alternative will never 
match". Nevertheless program runs perfectly and gives expected result 12.

Start = s [4]
will give type error that Int can not be unified with [v1], so s seems 
to have type s :: Int -> Int. But what about definitions with list as a 
parameter? Why there is no complains?

Again, warning seems to be incorrect.

How s in the example above is typed?

BTW How can I make "Types" window appear in Clean IDE?

-- 
Best regards,
Dmitry Malenko.
+----------------------------------------------------+
  Registered Linux user #258004
  ALT Linux Team                http://www.altlinux.ru
  Titano project         http://titano.sourceforge.net
+----------------------------------------------------+
Do you guys know what you're doing, or are you just hacking?