size of an IO list
Mon Mar 7 23:30:06 CET 2005
On Mon, Mar 07, 2005 at 10:11:34PM +0100, Kostis Sagonas wrote:
> I am trying to understand these IOLists and why this is an interesting
> data type to have in the first place, so please excuse my ignorance.
An IO list is a deep list (aka tree) of binarys and integers in the
range from 0 to 255. You use them to prepare output you want to write
to eg a file later on. The advantage over a simple list of ints is
that List1++List2 has to copy List1 while [List1,List2] only has to
allocate to cells.
> Before we agree on what their 'size' is, can we first agree on their
> definition and if we are happy with it, possibly also add this as a
> new guard?
> (An is_iolist/1 Erlang function will do as answer.)
Such a function would take time proportional to the length of the
list, which is why it probably would not be seen as suitable in
guards. OTOH size is allowed, although some see this is a design
error. Will io_list_size be allowed?
I hope that the following is accurate:
is_iolist_head(H) andalso is_iolist(T);
is_iolist_head(I) when is_integer(I) ->
(I>=0) and (I=<255);
is_iolist_head(B) when is_binary(B) ->
Carsten Schultz (2:38, 33:47)
PGP/GPG key on the pgp.net key servers,
fingerprint on my home page.
More information about the erlang-questions