Like with string-split (see separate reply) the specification for string-unfold-right
was copied (without much thought) from SRFI-135's text-unfold-right:
https://srfi.schemers.org/srfi-135/srfi-135.html#text-unfold-right
I don't think reversing the characters in a string is a useful operation,
so I don't think we should reverse the sub-string returned by the mapper.
I.e. the Kawa implementation is correct.
However, I could be convinced if reversing makes the procedure more useful.
On 3/2/20 3:12 PM, Arthur A. Gleckler wrote:
> Per, when you have a chance, would you please reply to Chris's comments below?
>
> Thanks.
>
> On Sun, Nov 17, 2019 at 6:34 PM Chris Hanson <xxxxxx@chris-hanson.org <mailto:xxxxxx@chris-hanson.org>> wrote:
>
> I'm implementing this SRFI and have noticed an ambiguity in the
> specification.
>
> string-unfold-right specifies that the results of the mapper procedure
> are accumulated from right to left in the result. When the mapper
> returns a character, that's not a problem, and the specification is
> clear.
>
> However, when the mapper returns a string, it's not specified how the
> characters of the string are accumulated. One might imagine the
> characters being prepended to the result one at a time in reverse order,
> as if it was returned by multiple calls to the mapper in the string
> order, or the string might be simply prepended to the output being
> built.
>
> I see that Kawa implements the latter.
>
> I don't care what the actual semantics are, as long as they are clearly
> specified.
>
> I suppose it's worth spelling out for string-unfold too, though in that
> case it seems like the obvious solution is to just append the string,
> since the two orders are congruent.
>
> Another concern would be whether someone expects that string-unfold and
> string-unfold-right have some kind of deep symmetry, in which the
> resulting strings are the reverse of one another, even when some mapper
> values are strings. In that case it might be more elegant to prepend
> the string's characters in reverse order rather forward order. I'm not
> making that argument, though I can understand the appeal. I just want a
> clear specification.
>
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/