Date: Wed, 25 Sep 2002 13:53:23 -0400 (EDT) From: Li Liao To: Sreedevi Sampath Subject: Re: hw 1 question > > When we say a list is of the type 'a list, does it mean that it is a > wildcard where 'a matches with either int or string or char etc.? Yes, it is polymorphic. But keep in mind, all elements of a list should have the same type. > > If yes, then when I declare my list of type 'a list and try to pass a > field of type char list as an element of the list, it gives me a > compilation error. What am I doing wrong? The only way I can think is to > define the list specifically to be a list of chars. How would I do that? > I do not know what exactly you did. It might be syntax errors, or sth else. You may want to send me the piece of code that you are having trouble with. Here just an example of what you described doing and it works fine. fun f s : 'a list = s; f [1, 2, 3]; f [[#"a"]]; In most cases, you do not have to declare the type of a variable, you just treat it that way (say in pattern matching) and ML will be able to figure out the right type! I hope this is helpful. Please let me know if you still have problem. Li