Boost logo

Boost :

From: vesa_karvonen (vesa_karvonen_at_[hidden])
Date: 2002-01-21 13:22:01


--- In boost_at_y..., Douglas Gregor <gregod_at_c...> wrote:
> On Monday 21 January 2002 06:53 am, you wrote:
> > //! Drops the first N elements of the list.
[...]
> > #define BOOST_PP_LIST_DROP(N,L)

> "Drop" doesn't really tell us anything about what's being dropped.
How about
> using REMOVE_FIRST instead, e.g.,
>
> BOOST_PP_REMOVE_FIRST(2,BOOST_PP_TUPLE_TO_LIST(4,(+,-,*,/)))
>
> Or, perhaps, to save typing, use REMOVE1ST.

The name "drop" is used for the same function in Haskell (and in
several other more or less functional languages). I agree that it may
sound a bit odd at first. The functions "drop" and "take" form a
logical couple.

What do you think about the name "take"?

I think that 'remove_first' certainly sounds more like STL,
but "drop" and "take" don't seem to have close enough relatives in
STL, so that the names could just be borrowed.

I think that "remove_first" sounds like it would work like "tail"
or "head" (depending on which part, "head" or "tail", is returned).

So, I like "drop" better than "remove_first". It is shorter, and I
don't find it difficult to make the leap from "drop" to "drop the
first N elements of a list".

> Otherwise, the naming is good

So, you like "fold_left" and "fold_right"?

I considered using "accumulate" (and "reverse_accumulate"
and "accumulate_left", etc...), but IMO it sounds way too arithmetic.
Also "fold" is well known concept in functional programming.
Furthermore I don't want to make it appear as if either one of the
folds would be more primitive.

> and the new facilities are very cool.

Thanks! :)

But you should really congratulate the people who invented functional
programming. The preprocessor list data structure is just a rather
straightforward implementation of functional lists.


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