Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Michel Quercia <quercia@cal.enst.fr>
To: "caml-list" <caml-list@inria.fr>
Subject: Re: [Caml-list] strange message
Date: Wed, 14 Mar 2001 21:23:24 +0000	[thread overview]
Message-ID: <01031421275709.07795@haguenauer> (raw)
In-Reply-To: <3AAFCD35.5CD57AD4@versailles.inra.fr>

Le Wed, 14 Mar 2001, vous [Antoine Marin] avez écrit :
> Sorry for this question, but I don't understand why I get this message for this
> small programme :

> let rec rev_write str_buf str_len str_pos = match str_buf.[str_pos] with
>   | '\n' -> output stdout str_buf (str_pos + 1) (str_len - str_pos);
>     rev_write str_buf str_len (str_pos - 1);
>   | _ -> rev_write str_buf str_len (str_pos - 1);;

Cette fonction boucle. Le compilateur attribue à rev_write le type
string -> int -> int -> 'a ce qui signifie que le résultat est indéterminé.
Voici un code correct :

let rec rev_write str_buf str_len str_pos =
  if str_len > 0 then
    match str_buf.[str_pos] with
      | '\n' -> output stdout str_buf (str_pos + 1) (str_len - str_pos);
                rev_write str_buf str_pos (str_pos - 1);
      | _ -> rev_write str_buf str_len (str_pos - 1)
;;

-- 
Michel Quercia
57 rue abbé Grégoire, 38000 Grenoble
http://pauillac.inria.fr/~quercia
mailto:michel.quercia@prepas.org
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


      parent reply	other threads:[~2001-03-14 20:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-14 19:57 Antoine Marin
2001-03-14 20:36 ` Antoine Marin
2001-03-14 21:23 ` Michel Quercia [this message]

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=01031421275709.07795@haguenauer \
    --to=quercia@cal.enst.fr \
    --cc=caml-list@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