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=2.8 required=5.0 tests=DNS_FROM_RFC_POST, HTML_MESSAGE,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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 53784BBAF for ; Sun, 22 Feb 2009 07:27:35 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnYCAD9/oEnRVd0VkGdsb2JhbACCRSyRLD8BAQEBCQkMBxEDr02BBY1mAQMBA4QMBg X-IronPort-AV: E=Sophos;i="4.38,248,1233529200"; d="scan'208";a="21503316" Received: from mail-qy0-f21.google.com ([209.85.221.21]) by mail2-smtp-roc.national.inria.fr with ESMTP; 22 Feb 2009 07:27:34 +0100 Received: by qyk14 with SMTP id 14so2416103qyk.3 for ; Sat, 21 Feb 2009 22:27:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=lMbIwNr8Lgr/TTcgKrU17gWDq3ubgB8pJgXluxYRX/o=; b=aTQYu7o3WhHYiGQAacoCLtVmsZxowFB+XvaDxgppsT3kKwzZC9iAlIH5bst0mnz8dn xgbmmsHCs6tzH3n1kjW+Nx1RNZZm8x2qmyNjjn7I82+qlZ6X37i3SIllgpMSnr28Q5fk pLrHMXYKhM1ZZQj0aPSdzjolvbgPADKiRVAvw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=S7hL8iZTL65IdHG7IxT1qQARh6kYV9eahjoAk1DNy4YCODrvq+ovXL36EUeoHA4w4D BWjevCpc/VaRUhkuiLcyBMi70rhP9d0SgkZ8x3fqWXO3gDcoJjXKTesxKyufH4/O8LXg 4hlHTgFsoEZCeCZTnOfAKIw5tIEROsNF+Jauc= MIME-Version: 1.0 Received: by 10.229.84.201 with SMTP id k9mr988568qcl.84.1235284053751; Sat, 21 Feb 2009 22:27:33 -0800 (PST) Date: Sun, 22 Feb 2009 00:27:33 -0600 Message-ID: Subject: a problem about type recongnition From: Su Zhang To: caml-list@yquem.inria.fr Content-Type: multipart/alternative; boundary=0016364ee2ea3876d104637bfbe5 X-Spam: no; 0.00; ocaml:01 rebuilt:01 rebuilt:01 compiler:01 ocaml:01 compiler:01 W10:98 W8:98 W8:98 W10:98 W6:98 rec:01 rec:01 int:01 int:01 --0016364ee2ea3876d104637bfbe5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --0016364ee2ea3876d104637bfbe5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
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 i= s in the following, you can take a look at the code and the info of the err= ors
 

<= font size=3D"3">let rec first(x, y, z)=3Dx

<= font face=3D"Calibri" size=3D"3">let rec second(x,y,z)=3Dy

<= font face=3D"Calibri" size=3D"3">let rec third(x,y,z)=3Dz

<= font face=3D"Calibri" size=3D"3"> 

<= font face=3D"Calibri" size=3D"3">let rec rebuilt anss  (m,n,ys)=3D match anss with

<= font size=3D"3">&n= bsp;      = ; []    &= nbsp;      ->       (m,n,ys) 

|element::anss ->

<= font size=3D"3">&n= bsp;        if m>first(element= ) and n< second(element)

<= font size=3D"3">&n= bsp;        then rebuilt anss (m,= n,ys)

<= font size=3D"3">&n= bsp;        else element::(rebuil= d anss (m,n,ys))

<= font face=3D"Calibri" size=3D"3"> 

<= font face=3D"Calibri" size=3D"3">let rec sum anss cur n ys=3D match cur wit= h

<= font size=3D"3">&n= bsp;          None   ->=

<= font size=3D"3">&n= bsp;            (match ys with

[]-> anss

|y::ys->

if y=3D0

then sum(rebuild anss (n,n,0)) None n+1 y= s

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:&q= uot;This expression has type int list -> 'a but is here used with ty= pe 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
Comp= uter Information and Science
Kansas State University
--0016364ee2ea3876d104637bfbe5--