size of an IO list

Sean Hinde sean.hinde@REDACTED
Fri Mar 4 00:01:21 CET 2005


I have also wished for this many times.

I often find myself going to extraordinary lengths to add up the total 
length in the same pass as creating some complex io_list. This makes 
for horrible code.

asn.1 encoding would also benefit greatly.

So Yes Please!
(from a paying customer :-) )

Sean

On 3 Mar 2005, at 08:14, Raimo Niskanen wrote:

> lists:flatlength/1 works on a deep list of numbers, but not if the
> list contains binaries, nor if the list or one of its sublists
> is an improper list with a binary at the tail, as allowed for
> I/O lists.
>
>
> luna@REDACTED (Daniel Luna) writes:
>
>> On Wed, 2 Mar 2005, Joe Armstrong (AL/EAB) wrote:
>>> How about a BIF to compute the size of an I/O list?
>>>
>>> Why?
>>>
>>> I have made a deep list that I want to output (guess what's it's 
>>> HTML :-)
>>>
>>> I need to make an HTTP header element  "Content-Length: ..."
>>>
>>> Which is the size of the flattened deep list , but I don't want to 
>>> flatten it (horrors)
>>> or traverse it (in Erlang) to find the length.
>>>
>>> Suitable case for a BIF?
>>
>> There is lists:flatlength/1 that does this, unfortunately it's not a 
>> BIF.
>>
>> /Luna
>> -- 
>> Daniel Luna                           | Top reasons that I have a 
>> beard:
>> luna@REDACTED                     |  a) Laziness.
>> http://www.update.uu.se/~luna/        |  b) I can.
>> Don't look at my homepage (it stinks).|  c) I can get away with it.
>
> -- 
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB




More information about the erlang-questions mailing list