Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Doing the transition from imperative to functional (and some other Q)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] Doing the transition from imperative to functional (and some other Q)
> Now comes the funny part.  Actually, right now I'm not sure how to
> represent the buffer variable internally.  As you can see, in the first
> part I chose string, because of the .[] operator.  However, I cannot use
> string, because this data type doesn't have any fold function.  Right
> now I do not want to make a decision about the data type used, except
> that I know that it must be a sequence of characters.
> Though I am a strong believer in static typing, above versions
> disappoint me heavily because of type restrictions.  Is there any way to
> write above version on arbitrary sequences like Arrays, Lists, Strings?
> Actually, I would have preferred the buffer data type because I can use
> that one for fast reading of a file.  However, I cannot fold over a
> buffer :(
> Any enlightening hints?

You should have a look at ExtLib Enum module that enable you to apply fold's
and others functionals operations on any underlying data structure (string,
array, list, .... ).

Nicolas Cannasse

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: