4 ms·
I'm pretty sick of all high-level languages actually. I even wrote my own functional programming language "Fexl", and I'm sick of it too. Here's a totally gen
by fexl 13y ago
I'm pretty sick of all high-level languages actually. I even wrote my own functional programming language "Fexl", and I'm sick of it too. Here's a totally general purpose quicksort:
# (sort keep compare xs) sorts the list xs using the three-way comparison
# function. It keeps duplicates if the keep flag is true, otherwise it
# discards them and returns only the unique entries.
\sort =
(@\sort\keep\compare\xs
xs [] \x\xs
\lo = (filter (\y compare y x T F F) xs)
\hi = (filter (\y compare y x F keep T) xs)
\sort = (sort keep compare)
append (sort lo) [x; sort hi]
)
I'm tired of all of it. The language I really like is plain old C.
To handle arbitrary strings reliably, I can just use this code:
https://github.com/chkoreff/Fexl/blob/master/src/str.h https://github.com/chkoreff/Fexl/blob/master/src/str.h
https://github.com/chkoreff/Fexl/blob/master/src/str.c https://github.com/chkoreff/Fexl/blob/master/src/str.c
To deal with dynamic allocation, detecting any memory leaks upon program exit, I use this:
https://github.com/chkoreff/Fexl/blob/master/src/memory.h https://github.com/chkoreff/Fexl/blob/master/src/memory.h
https://github.com/chkoreff/Fexl/blob/master/src/memory.c https://github.com/chkoreff/Fexl/blob/master/src/memory.c
For high-speed buffering of data, one character at a time, I can use this:
https://github.com/chkoreff/Fexl/blob/master/src/buf.h https://github.com/chkoreff/Fexl/blob/master/src/buf.h
https://github.com/chkoreff/Fexl/blob/master/src/buf.c https://github.com/chkoreff/Fexl/blob/master/src/buf.c