[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initial value for unfold(-right)

This page is part of the web mail archives of SRFI 117 from before July 7th, 2015. The new archives for SRFI 117 contain all messages, not just those from before July 7th, 2015.



On Sun, Jan 11, 2015 at 3:39 AM, Takashi Kato <ktakashi@xxxxxxxxx> wrote:
 
I don't quite get the idea so just to clarify. Does this mean if the
optional argument is given like this:
(list-queue-unfold (lambda (seed) (zero? seed))
                   (lambda (seed) (* seed seed))
                   (lambda (seed) (- seed 1))
                   10
                   '(a b c))
Then the queue storage would look like this?
(100 81 64 49 36 25 16 9 4 1 a b c)

Yes, except that I was proposing that the initial argument be a list-queue, not a list, to facilitate using list-queue-unfold to add to an existing queue.

(I made the suggestion privately only by accident.  I was responding using a cell phone and fumbled with the UI.)

 If this is the case, I think it's rather weird. I would expect that all
elements have the same type (or at least the types mapper procedure
returns). But if the procedures are allowed to take the tail elements, this expectation would be broken.

I don't see why types are relevant here in particular.  If the caller doesn't want different types, he shouldn't supply an initial list-queue that holds a different type.  That's just a programming error, not an error in the API.