From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id E6E13BBAF for ; Sun, 22 Feb 2009 10:01:22 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhYCAKejoElKfU4blGdsb2JhbACNEIcOPwEBAQEJCwgJEQOwCYEFjVgBAwEDhAwG X-IronPort-AV: E=Sophos;i="4.38,249,1233529200"; d="scan'208";a="23336360" Received: from ey-out-2122.google.com ([74.125.78.27]) by mail3-smtp-sop.national.inria.fr with ESMTP; 22 Feb 2009 10:01:22 +0100 Received: by ey-out-2122.google.com with SMTP id 9so182873eyd.15 for ; Sun, 22 Feb 2009 01:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=bPnzc1e9py5+O/iTm5knrgpEa+/WEoa6A6pLjpyszG8=; b=oFYYbW7WcQr4ZZPP+ZWzaZv4ptXaf8+o0Bq+jjfaNGl59chfUDurYiSecEMVyvcv6u DHQsRIldDlzn0kDXsT/XSyLY9bkKahoOblvHNTZtIkAMAKLHlW8jCiz7IfhBT1gKzJhv OpFq6+75veYpnhcOCfliPgyOUESx6tpwOJoBQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=NSzFVQwnss5eYLEzfTxWo1K9gZsdpj+GTBVDauwmLe7JVfW5/6+I29v+Uyb3ewb3dg mu7riZIuMdU2Y+Ui3/kXUfM2nqrBlmySsf6/BCUvKbfcNNld8Im4hZ1+cEGbB9CHz++e 2i/8AxcLA5HFHhXn6QE3oR0iRG0aXce/mZn84= MIME-Version: 1.0 Received: by 10.210.76.4 with SMTP id y4mr2371589eba.11.1235293282254; Sun, 22 Feb 2009 01:01:22 -0800 (PST) In-Reply-To: References: Date: Sun, 22 Feb 2009 10:01:22 +0100 Message-ID: <527cf6bc0902220101y15fddcf2p8362009f48d9b59b@mail.gmail.com> Subject: Re: [Caml-list] a problem about type recongnition From: blue storm To: Su Zhang Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 ocaml:01 rebuilt:01 rebuilt:01 compiler:01 storm:98 beginners:01 wrote:01 rec:01 rec:01 caml-list:01 int:01 int:01 expression:02 match:02 You need parenthesis around (n+1), and it's "if m>first(element ) && n< second(element)" : "and" is an OCaml keyword. There is a beginner list ( http://groups.yahoo.com/group/ocaml_beginners ) that would probably be more suited to those questions. On 2/22/09, Su Zhang wrote: > Hi all, > > I have a problem while executing ocaml, did you see any problem in my code? > and do I need to give each variable a type before I use it ?my code is in > the following, you can take a look at the code and the info of the errors > > > let rec first(x, y, z)=x > > let rec second(x,y,z)=y > > let rec third(x,y,z)=z > > > > let rec rebuilt anss (m,n,ys)= match anss with > > [] -> (m,n,ys) > > |element::anss -> > > if m>first(element ) and n< second(element) > > then rebuilt anss (m,n,ys) > > else element::(rebuild anss (m,n,ys)) > > > > let rec sum anss cur n ys= match cur with > > None -> > > (match ys with > > []-> anss > > |y::ys-> > > if y=0 > > then sum(rebuild anss (n,n,0)) None n+1 ys > > else sum anss (Some(n, y, [y])) (n + 1) ys) > > > the red area is shown has an error, and the error info is like this:"This > expression has type int list -> 'a but is here used with type int", so would > you please let me know if possible how can I let the compiler know the type > of anss is a list but not an integrer? > > thank you > -- > Su Zhang > PHD Student > Computer Information and Science > Kansas State University >