Re: Functional programming with GLib



Hi

Why not doing a different approach? Provide serialization to your list
and pass it to AgsFunction?

I would love to see something alike in GSequencer. Thus I did a boxed
type AgsComplex.
The mention object above shall be able to solve mathematical equations.

Note I is not implemented for now. But feel free to provide solver strategies ;)
The goal is to let the user describe its synth by a formula.

nongnu.org/gsequencer

Bests,
Joël


On Sun, Apr 23, 2017 at 8:46 PM, Dirk-Jan C. Binnema
<djcb bulk gmail com> wrote:

Hi All,

A while back, I wrote some functions for functional-flavored programming
with GLib. It's fully documented[1], has tests, etc.

It would (for me at least) be useful to have some of these functions in
GLib-proper, but I suspect the GLib-maintainers are not /too/ eager to
accept contributions to GList... anyway, perhaps its useful for others.

As a simple example, suppose we want to calculate the sum of primes up
to 100 (a common task after all):

,----
| int    sum;
| GList *nums, *primes;
|
| nums   = gx_list_iota (100, 1, 1);
| primes = gx_list_filter (nums, (GXPred)gx_is_prime, NULL);
| sum    = gx_list_sum (primes); /* => 1060 */
|
| g_list_free (nums);
| g_list_free (primes);
`----

There's also folding, mapping etc. See a short article about this:
   http://www.djcbsoftware.nl/2015/10/04/functional-glists/
(2015?! time does fly). Am still developing it though.

Repo: https://github.com/djcb/gxlib
Docs: http://www.djcbsoftware.nl/code/gxlib/

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema                  Helsinki, Finland
e:djcb djcbsoftware nl           w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


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