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] [ANN] The Missing Library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-28 (12:38)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] [ANN] The Missing Library
> > Why can't you do this kind of in ocaml?  Returning something like a
> > "next" function would seem to give you a very basic (but usable)
> > iterator.  Which part of the iterator abstraction can't you do?
> I suggest you try it. I don't know how to answer the question.
> I think the answer is 'C++ templates provide functorial
> polymorphism (polyadicity), Ocaml has no such expressive power.'
> HOF's like 'map' and 'fold' make sense
> for polynomial data structures -- lists and trees etc.
> But you have to write '' or ''. There
> is no single 'map' which works for all data structures
> in Ocaml.

There is ExtLib that's pretty good at doing that.

> There is in C++, and its a one line idiom:
> // STL copy
> for(; i!=e; ++i) *o++ = *i++;
> Fold is as easy to define (called Accumulate in STL).
> These definitions are polyadic. They work for ALL
> data structures -- provided they have iterators
> of course :D

That's exactly the same as ExtLib enums : define an enumerator for your data
structure, and you can apply a full range of algorithms on it. I don't
really understand the difference with  STL.

Nicolas Cannasse

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