chickadee » srfi-217 » iset-unfold

iset-unfold stop? mapper successor seedprocedure

Create a newly allocated iset as if by iset. If the result of applying the predicate stop? to seed is true, return the iset. Otherwise, apply the procedure mapper to seed. The value that mapper returns is added to the iset. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.

Examples:

   (iset->list (iset-unfold (lambda (n) (> n 64))
                            values
                            (lambda (n) (* n 2))
                            2))
    ⇒ (2 4 8 16 32 64)