Re: useful list functions



On 7 Aug 2000, Maciej Stachowiak wrote:

> >   typedef gpointer (*ListMapFn)( gpointer, gpointer ); 
> >   gpointer slist_map( GSList *list, 
> >     ListMapFn user_func, gpointer user_data );
> > 
> > This is like for_each, but has a 'bail out'. If user_func returns NULL,
> > _map() tries the next element. If user_func returns non-NULL, the loop
> > stops and slist_map() returns that value as its result. If user_func
> > returns NULL for all elements, _map() returns NULL.
> 
> That's very different from the usual meaning of `map'. In fact, it is
> kind of similar to g_list_find_custom.

You are right, it is not really like map.

> Yes, I was considering adding `fold' (also known as `reduce'), but it
> brings up tricky memory management issues when you don't have GC,
> i.e. how to ensure all the intermediate values are freed if necessary.

I know ;)

That reminds me:  how difficult would it be to make an ordinary GTK+ (or
Gnome) program to work with the Boehm garbage collector?

> Shhh! I'm trying to turn glib into Lisp one small step at a time!
> Don't give away the game :-)

A noble goal :)

-Peter

The only "intuitive" interface is the nipple. After that, it's all learned.
(Bruce Ediger, bediger@teal.csn.org, in comp.os.linux.misc, on X interfaces.)






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]