caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Scanf.sscanf surprised me
@ 2013-10-08  2:58 Francois Berenger
  2013-10-08  3:28 ` Robert Roessler
  2013-10-08 15:23 ` Eric Cooper
  0 siblings, 2 replies; 4+ messages in thread
From: Francois Berenger @ 2013-10-08  2:58 UTC (permalink / raw)
  To: caml-list

This example line and scanning format work:

# let line = "active_ZINC01535869 
0.470,0.389,0.479,0.453,0.470,0.631,0.562,0.590,0.677,0.558,0.379";; 
                                                       val line : string =
   "active_ZINC01535869 
0.470,0.389,0.479,0.453,0.470,0.631,0.562,0.590,0.677,0.558,0.379"
# Scanf.sscanf line "%s %f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f" (fun name s1 
s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 -> (name, s1, s2, s3, s4, s5, s6, s7, 
s8, s9, s10, s11));;
- : string * float * float * float * float * float * float * float *
     float * float * float * float
=
("active_ZINC01535869", 0.47, 0.389, 0.479, 0.453, 0.47, 0.631, 0.562, 
0.59, 0.677, 0.558, 0.379)

This one doesn't:

# let line = 
"active_ZINC01535869,0.470,0.389,0.479,0.453,0.470,0.631,0.562,0.590,0.677,0.558,0.379";; 
                                                          val line : 
string =
 
"active_ZINC01535869,0.470,0.389,0.479,0.453,0.470,0.631,0.562,0.590,0.677,0.558,0.379"
# Scanf.sscanf line "%s,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f" (fun name s1 
s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 -> (name, s1, s2, s3, s4, s5, s6, s7, 
s8, s9, s10, s11));;
Exception: End_of_file.

I am quite surprised.
I was expecting the first separator being a space or a coma
to behave the same.

-- 
Best regards,
Francois Berenger.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-08 15:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-08  2:58 [Caml-list] Scanf.sscanf surprised me Francois Berenger
2013-10-08  3:28 ` Robert Roessler
2013-10-08  4:30   ` Gabriel Scherer
2013-10-08 15:23 ` Eric Cooper

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).