-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hello, I also use glib in a somewhat functional style. The most useful primitive I've found is a simple iterator with a function argument:
https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/util.c#L114
It walks down the GSList calling a function for every data element, stopping either when the list is exhausted (in which case it returns NULL) or stopping when the function returns non-NULL and returning that value. It's somewhat like find, I suppose, or forall, but with early termination.
It takes a shallow copy of the list, so the callback can modify the list if it wishes. Since it uses NULL to mean terminate, the list cannot contain NULL values, but I've not found this a problem in practice.
Anyway, another possibility.
Metadata
Metadata
Assignees
Labels
No labels