Prof. Dr. Johannes Grabmeier wrote:
>
> discovered a strange behaviour of the split function for Strings:
>
> A very natural application is to read in a CSV file and get as many
> Strings - possibly empty ones - as the number of occurencies of the
> splitting character indicates (+1):
>
> However:
>
> (1) -> line := "A;B;;C;;"
>
> (1) "A;B;;C;;"
> Type:
> String
> (2) -> c := char ";"
>
> (2) ;
> Type:
> Character
> (3) -> split(line, c)
>
> (3) ["A","B","C"]
> Type:
> List(String)
>
> This is not what I expect.
<snip>
> If there are good reasons - would like to know - for the current
> implementation, then I would suggest to add a second a pair of split
> functions of this behaviour, otherwise I would suggest to switch to this
> interpretation.
The first example for 'split' (and probably the only one in FriCAS
book) is to split on spaces. In such case the expected behaviour
is to treat several consecutive spaces as a single separator.
So yes, there is good reason for current implementation. OTOH
what you expect is reasonable too. In other languages there is
quite a lot of functions which perform various splitting/parsing
tasks. ATM I am not sure if we should add a second version of
split or some more general function...
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.