caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nicolas Cannasse" <warplayer@free.fr>
To: "Diego Olivier Fernandez Pons"
	<Diego-Olivier.FERNANDEZ-PONS@cicrp.jussieu.fr>
Cc: "Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Two types of efficiency (Was Efficiency of 'a list)
Date: Wed, 7 May 2003 11:05:35 +0900	[thread overview]
Message-ID: <006301c3143d$25b511d0$2713f9ca@WARP> (raw)
In-Reply-To: <Pine.A41.4.44.0305061427040.1466570-100000@ibm1.cicrp.jussieu.fr>

> > Few people here are currently running the "ExtLib" - ocaml extended
> > library - project, and are trying to answer theses questions. For an
> > example of a structure that can be used to convert from and between
> > several different data structures, you could have a look at the Enum
> > module from the ExtLib CVS here :
>
> I read the code but I am afraid I didn't catch the point : what is the
> difference between the 'enum' data structure and a ('a * int) stream ?

I agree that an Enum is near from a Stream, but it differs in several points
:
- as it is purely functional, you can create quite exotic count and next
functions, while Stream.from is only working with indexes, and is having a
little cost due to the usage of 'a option instead of an exception.
- Enum provide easy support for functional operations such as map, while
doing it with stream require a little bit of thinking (and from usage)
- with a stream, you have access to a "next" functions : you cannot do
something like this with Enum . In most cases, you always want to process
all your elements in the same way. Enum does not provide user access to
next, you can only do iter.

In a short way : Stream is designed more as a "tokenizer" where you're
querying items one by one, while Enum is more an uniform collection of
items, abstracted in a purely fonctional way.

> Why is it more convenient than other data structures as an itermediate
> data representation ?

It's not a data structure since it does not physically store any elements,
it can be seen as a common interface from different data structures wanting
to provide support for it. See ExtList.of_enum , ExtList.enum,
ExtArray.of_enum and ExtArray.enum , one can do the following :

let e = ExtList.enum l in
let e' = Enum.map f e in
ExtArray.of_enum e'

To map-and-convert a list to an array. Quite convenient in fact, but I agree
Enum is not the Graal of functionnal programming, just a small convenient
interface.

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


  reply	other threads:[~2003-05-07  2:06 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-02 19:27 [Caml-list] Efficiency of 'a list Eray Ozkural
2003-05-03  5:43 ` Mattias Waldau
2003-05-03  8:16   ` Ville-Pertti Keinonen
2003-05-03 14:12   ` Vitaly Lugovsky
2003-05-03 18:43     ` Mattias Waldau
2003-05-03 20:01       ` Eray Ozkural
2003-05-03 23:17       ` Eray Ozkural
2003-05-04  2:08       ` cashin
2003-05-04  4:08         ` alc
2003-05-04  5:32           ` Ed L Cashin
2003-05-04  6:46           ` [Caml-list] Two types of efficiency (Was Efficiency of 'a list) Mattias Waldau
2003-05-04  7:35             ` John Max Skaller
2003-05-04 11:52               ` Olivier Andrieu
2003-05-05 11:04                 ` John Max Skaller
2003-05-04 16:48               ` brogoff
2003-05-04  7:43             ` Ville-Pertti Keinonen
2003-05-04 12:50               ` Eray Ozkural
2003-05-04 12:48             ` Eray Ozkural
2003-05-05  7:31             ` Diego Olivier Fernandez Pons
2003-05-05 11:11               ` Mattias Waldau
2003-05-05 13:17                 ` John Max Skaller
2003-05-05 11:49               ` Eray Ozkural
2003-05-05 11:57               ` Yaron M. Minsky
2003-05-05 13:32                 ` John Max Skaller
2003-05-06  2:49                   ` Nicolas Cannasse
2003-05-06 12:30                     ` Diego Olivier Fernandez Pons
2003-05-07  2:05                       ` Nicolas Cannasse [this message]
2003-05-05 16:38                 ` Diego Olivier Fernandez Pons
2003-05-05 18:05                   ` Eray Ozkural
2003-05-06 13:28                     ` Diego Olivier Fernandez Pons
2003-05-13 11:35                   ` [Caml-list] Data Structure Libraries (was: Two types of efficiency) Oleg Trott
2003-05-04  7:55           ` [Caml-list] Efficiency of 'a list Ville-Pertti Keinonen
2003-05-04 10:56             ` Neel Krishnaswami
2003-05-04 12:56               ` Eray Ozkural
2003-05-04 13:35                 ` Falk Hueffner
2003-05-04 12:38           ` Eray Ozkural
2003-05-04  8:07         ` Ville-Pertti Keinonen
2003-05-04 15:54           ` Ed L Cashin
2003-05-05 23:52           ` Garry Hodgson
2003-05-03 20:03   ` Eray Ozkural
2003-05-03 21:13 ` Lauri Alanko
2003-05-03 22:03   ` Eray Ozkural

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='006301c3143d$25b511d0$2713f9ca@WARP' \
    --to=warplayer@free.fr \
    --cc=Diego-Olivier.FERNANDEZ-PONS@cicrp.jussieu.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).