@hi in my opinion some aspects of fp are useful when writing C (consts are great, pure functions, functional pointers), but for a full fp experience you need tco, garbage collection (and it means no hardened OpenBSD malloc for you). Libraries-wise Glib will give you some useful structures using native malloc, but bdwgc for example is not going to use it, and because it's conservative, performance will be abysmal.
Why use C? OCaml is right there, works great on OpenBSD
i'd like to keep things as simple as possible, and c works out of the box in #opensbd. i'll try sticking with native malloc and see how far i can get
@hi well, fp simplicity for the developer comes at a cost for underlying platform, but I get the idea. sys/queue.h and sys/tree.h have some structures you might find useful.
It might depend on how you go about it and what you expect of it. Basic anonymous-functions might be possible (depending on the version of C), but closures (and managing their storage lifetime) might be more challenging.
map: doable with macros (the sys/queue.h header has good examples of things like the *_FOREACH macros). They tend to be macros because the exact method of iteration would differ depending on the data-structure over which you're iterating (iterating over a single-linked-list is different from iterating breadth-first over a tree is different from iterating depth-first over a tree, all of which are different from iterating over a trie or btree)
reduce: I'd have to think a bit harder on that, but I suspect it would involve similar FOREACH-style macros
immutability/pure functions: using "const" on appropriate functions/parameters and ensuring that you don't modify parameters. There might be some complexity if you're trying to support older C standards (IIRC, the ability to return non-simple types from functions was added later), so they might end up being semi-pure functions where a parameter is used to designate the function-output location for more complex data-types like structs/unions
recursion: has always been there in C 🙂