From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 5ABD6BB9A for ; Thu, 27 Oct 2005 15:28:58 +0200 (CEST) Received: from fm100.galaradio.com (fm100.galaradio.com [195.245.81.26]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j9RDSv0S001343 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 27 Oct 2005 15:28:58 +0200 Received: from shaka.x.gala ([10.0.0.88]) by fm100.galaradio.com with esmtp (Exim 4.50) id 1EV7oP-0002oK-JP for caml-list@yquem.inria.fr; Thu, 27 Oct 2005 16:28:57 +0300 Subject: Beginner's question. From: "Alexander A. Vlasov" To: caml-list@yquem.inria.fr Content-Type: text/plain Organization: Gala.Net Date: Thu, 27 Oct 2005 16:30:08 +0300 Message-Id: <1130419808.12902.13.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4360D619.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; beginner's:01 ocaml:01 rec:01 rec:01 mismatch:01 transformers:01 zulu:98 ...:98 tail:01 tail:01 expression:01 func:01 func:01 tuple:02 alexander:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Hello. I'm making my first steps in OCaml and trying (just for expirience) to implement a simple function which applies given function to all elements of given list. I successfully did it using if/then/else let rec map func lst = if lst = [] then [] else (func (List.hd lst)) :: (map func (List.tl lst)) ;; But I can't do it using pattern matching -- following function doesn't work let rec mapm func lst = function | ( _, [] ) -> [] | ( _, head::tail ) -> (func head) :: (mapm func tail) ;; I get type mismatch error: characters 39-55: This expression has type 'a * 'b list -> 'c list but is here used with type 'c list But wait, ``map func (List.tl lst)'' in first example has the same type, isn't it? Both right parts in first and second example are, say, transformers from a tuple ( something, list-of-something-else ) to list-of-something-else. I understand that I missed something, so please tell me what. and... thank you for your patience 8) -- Best regards, Alexander A. Vlasov.