Boost logo

Boost :

Subject: Re: [boost] Assign V2 - first impression
From: er (er.ci.2020_at_[hidden])
Date: 2011-06-24 14:38:16


On 6/24/11 2:17 PM, Stewart, Robert wrote:
> er wrote:
>> On 6/24/11 9:08 AM, Stewart, Robert wrote:
>>> er wrote:
>>>>
>>>> "Create data elements by mapping 1, 10, 100, 1000 by
>>>> function f, and insert each result in cont by invoking
>>>> modifier push_front."
>>>
>>> If I interpret that correctly, it would be clearer as:
>>>
>>> "Create elements in cont, using push_front(), by calling f()
>> 1, 10, 100, and 1000 times."
>>
>> Apologies, I misread this. It should be :
>>
>> Map 1, 10, 100, and 1000 by function f,
>> which yields f( 1 ), f( 10 ), f( 100 ), f( 1000 )
>> and insert each, n times, using push_front, in cont.
>
> I see now. The "map" terminology obscures things somewhat. I prefer to see mention of "insert," "cont," and "push_back" near the beginning as the purpose of the operation is to insert elements into the container using push_back().
>

Yes, thanks, my use of the word map is because in the tutorial in
expression ( _data = f ), f is mathematical function. 'Calling' f is
indeed context free.

> IOW, something more like the following would suit me better:
>
> Insert elements in cont, using push_front(), where the
> values are generated by calling f() n times with 1, 10,
> 100, and 1000, in turn.

Thanks for trying to get to the bottom of it. I agree that the wording
in English might call for Insert in the beginning. But the actual
sequence of events is like this:

Each of x = 1, ..., 1000 is forwarded to a data-generator, f.
The result of f( x ), which I call y, is forwarded to a modifier which,
here, executes:
     repeat n times { cont.push_front( y ); }

The sequence matters, because f( x ) is computed only once, which is the
most efficient way.

I use the words data-generator & modifier to be consistent with the
naming conventions of the library. To be clear, the data-generator's job
is to map arguments to a suitable data-element. The modifier's job is to
insert that element (n times, in this case).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk