Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "William D. Neumann" <wneumann@cs.unm.edu>
To: Jean-Christophe Filliatre <filliatr@lri.fr>
Cc: Basile STARYNKEVITCH <basile@starynkevitch.net>,
	caml-list@yquem.inria.fr
Subject: Re: [Caml-list] printf & scanf oddity
Date: Fri, 27 Jan 2006 08:48:29 -0700 (MST)	[thread overview]
Message-ID: <Pine.LNX.4.62.0601270844210.28053@ganymede.cs.unm.edu> (raw)
In-Reply-To: <17370.13510.885701.379425@gargle.gargle.HOWL>

On Fri, 27 Jan 2006, Jean-Christophe Filliatre wrote:

> See "integer literals" in the manual :
> http://caml.inria.fr/pub/docs/manual-ocaml/manual009.html
>
> But I agree with you: this is wierd and almost a bug...

Even more clearly, see the Scanf module documentation.  From page 349 of 
the 3.09 manual:

*in addition to relevant digits, _ characters may appear inside numbers 
(this is reminiscent to the usual Caml conventions). If stricter scanning 
is desired, use the range conversion facility instead of the number 
conversions.

So, for example, this works:
# Scanf.sscanf "_a14_f2" "_a%[0-9]_f%[0-9]" (fun x y -> x,y);;
- : string * string = ("14", "2")

Though the return type is string, not int, so you'd need to convert them 
if you want ints...

William D. Neumann

---

"There's just so many extra children, we could just feed the
children to these tigers.  We don't need them, we're not doing 
anything with them.

Tigers are noble and sleek; children are loud and messy."

         -- Neko Case

Life is unfair.  Kill yourself or get over it.
 	-- Black Box Recorder


  reply	other threads:[~2006-01-27 15:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-27 14:26 Basile STARYNKEVITCH
2006-01-27 14:57 ` [Caml-list] " Jean-Christophe Filliatre
2006-01-27 15:48   ` William D. Neumann [this message]
2006-01-27 15:03 ` Virgile Prevosto

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=Pine.LNX.4.62.0601270844210.28053@ganymede.cs.unm.edu \
    --to=wneumann@cs.unm.edu \
    --cc=basile@starynkevitch.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=filliatr@lri.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