> Hello list,
>
> Currently, if using Neko UTF8 API, iteration over a UTF8 string will
> be slow as it is only possible as smth like
> for (index in 0...neko.Utf8.length(s)) {
> var char = neko.Utf8.charAt(index);
> }
> this takes n^2 operations where n is the string length since each
> charAt() call has to go through all the previous part of string
> looking for the correct character.
>
> Is there any way to make an Utf8 iterator - it can look like
> for (char in neko.Utf8.chars(s)) {
> // do whatever you like
> }
>
> and the iterator would just advance each time, not go through all
> the string - this will make it linear of string length, which is
> normal practice.
You can do :
neko.Utf8.iter(s,function(char) {
// do something
});
Nicolas
--
Neko : One VM to run them all
(http://nekovm.org)