From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA15762; Thu, 2 Aug 2001 15:01:22 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA15758 for ; Thu, 2 Aug 2001 15:01:21 +0200 (MET DST) Received: from ionie.inria.fr (ionie.inria.fr [128.93.39.12]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f72D1GX22804; Thu, 2 Aug 2001 15:01:16 +0200 (MET DST) Received: from ionie.inria.fr (localhost [127.0.0.1]) by ionie.inria.fr (8.11.1/8.10.0) with ESMTP id f72D1GT08449; Thu, 2 Aug 2001 15:01:16 +0200 (MET DST) Message-Id: <200108021301.f72D1GT08449@ionie.inria.fr> X-Mailer: exmh version 2.1.1 10/15/1999 To: Johann Spies cc: ocaml mailing list Subject: Re: [Caml-list] Please help a newbie In-Reply-To: Message from Johann Spies of "02 Aug 2001 13:42:13 -0000." <87lml2a896.fsf@#maties.sun.ac.za> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Thu, 02 Aug 2001 15:01:16 +0200 From: Francois Thomasset Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Answer of another newbie: several things are wrong in your piece of code: 1/ 'a' is a char, and print_string works for strings, noted "a" 2/ your wys_die_lys has 2 arguments, as can be seen from the signature val wys_die_lys : 'a -> string list -> unit list = (the system deduced the string list type for the type of the second argument from the call to print_string in wys_dit). The 1st argument is named l, but you do pattern matching on the 2nd (which has no name). So wys_die_lys lys is another function: wys_die_lys lys;; - : string list -> unit list = If you provide a list of chars as a 2nd argument to wys_die_lys it is rejected by the type checking: wys_die_lys lys lys;; This expression has type char list but is here used with type string list Normal: see point 1/ above. 3/ Now if you give a string list as 2nd argument: wys_die_lys lys ["a";"b";"c"];; cba- : unit list = [(); (); ()] The 1st argument lys is just passed around, and in fact ignored; wys_dit does its printing job and returns a unit to its caller, hence the list of units which is the result. 4/ Here is a definition which gets closer to what you expected: let wys_dit woord = print_char woord;; val wys_dit : char -> unit = let rec wys_die_lys = function [] -> () | h :: t -> begin wys_dit h ; wys_die_lys t end;; val wys_die_lys : char list -> unit = Now the units returned by calls to wys_dit are discared thanks to the sequence operator ` ; '. Note you have to pack the sequence between begin..end in an alternative, after the ` '-> ' # wys_die_lys lys;; abc- : unit = () Best Regards -- François Thomasset. INRIA (A3) Tel: +33 (1) 39-63-54-75 Fax: +33 (1) 39-63-53-30 ou +33 (1) 39-63-59-95 Email: Francois.Thomasset@inria.fr Smail: INRIA, Rocquencourt, BP 105, 78153 Le Chesnay Cedex, France ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr