Browse thread
[Caml-list] Doing the transition from imperative to functional (and some other Q)
-
Christian Schaller
- Yamagata Yoriyuki
- Nicolas Cannasse
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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, .... ). http://ocaml-lib.sf.net Regards, Nicolas Cannasse ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners