Add support for character arrays
milancurcic opened this issue · 4 comments
Adding support for character arrays would open up a plethora of functionality for manipulating strings. Given proper interfaces, the following functions should be useful for manipulating character strings: complement
, filter
, fold[lrt]
, head
, init
, insert
, intersection
, iterfold
, last
, map
, reverse
, set
, sort
, tail
, union
.
This would simply be a matter of interpreting the character encoding for a numeric representation yes?
What route did you end up taking?
I don't think encoding is needed at all. I think the key to reusing existing implementations for numeric types, most of them operating on 1-d arrays, is to convert a string to an array of 1-character elements. I did this with transformation functions arrstr
and strarr
(see https://github.com/wavebitscientific/functional-fortran/tree/feature/support-strings). Only head_char
and init_char
implemented so far. To be honest, I had forgotten I started this as I ended up not needing it in my work. But it'd be nice to wrap it up, so thank you for the reminder! :)
A few seconds after I hit comment I understood what you meant by character to numeric encoding. Yes, this may be an even easier approach than converting strings to arrays of single chars.
These functions are now compatible with character strings in the feature/support-strings branch: empty
, head
, init
, insert
, last
, reverse
, set
, sort
, tail
, and union
.