caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Su Zhang <westlifezs@gmail.com>
To: caml-list@yquem.inria.fr
Subject: a problem about type recongnition
Date: Sun, 22 Feb 2009 00:27:33 -0600	[thread overview]
Message-ID: <e2842950902212227p467f8df1n14e66a4b50d90580@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 4882 bytes --]

             reply	other threads:[~2009-02-22  6:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-22  6:27 Su Zhang [this message]
2009-02-22  9:01 ` [Caml-list] " blue storm
     [not found] ` <a58674cc0902212303w70a8b5eas956ef2a91968fb@mail.gmail.com>
     [not found]   ` <e2842950902220647m655729dew918962deec232c1@mail.gmail.com>
2009-02-22 14:50     ` Fwd: " Su Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e2842950902212227p467f8df1n14e66a4b50d90580@mail.gmail.com \
    --to=westlifezs@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).