* Stream parsing - caml light vs. ocaml
@ 1998-06-01 5:22 Norman Davis
1998-06-01 10:48 ` Toby Moth
0 siblings, 1 reply; 2+ messages in thread
From: Norman Davis @ 1998-06-01 5:22 UTC (permalink / raw)
To: caml-list
Hello,
I am reading "Functional programming using Caml Light" by Michel Mauny, chapter
10 on Streams and Parsers. The "spaces" function (used to remove the next
continuous segment of whitespace) shown there is :
# let rec spaces = function
# [< '' '|'\t'|'\n'; spaces _ >] -> ()
#| [< >] -> ();;
I tried converting it to Objective Caml :
# let rec spaces = parser
[< '' '|'\t'|'\n'; spaces >] -> ()
| [< >] -> ();;
val spaces : char Stream.t -> unit = <fun>
# let s = Stream.of_string " ;";;
val s : char Stream.t = <abstr>
# spaces s;;
- : unit = ()
# Stream.next s;;
- : char = ' '
# Stream.next s;;
- : char = ';'
The stream s had two space characters followed by a semicolon.
After "spaces s", I expected "Stream.next s" to return
a semicolon. What is the correct way to write "spaces" so that it removes all
whitespace from the front of the stream, not just a single whitespace
character.
Thanks.
Norman Davis
ndavis@ti.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-06-01 11:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-01 5:22 Stream parsing - caml light vs. ocaml Norman Davis
1998-06-01 10:48 ` Toby Moth
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).