I've written a version of `set-choose', and also `set-first' and `set-rest' (with the obvious meanings) a few times. They can be useful.

(I always waffled about whether to use just `set-choose', or `set-first' along with `set-rest'. Mathematically, `set-first' and `set-rest' don't make sense, but they're easier to code with.)

Neil T

Ryan Culpepper wrote:
I think a function named set-choose should return just the chosen element. I would call the function below set-split, maybe.

Also, beware that for/first returns #f if the sequence is empty.

Ryan

On 11/11/2010 01:38 PM, Jay McCarthy wrote:
I think it is a good idea. Any objectors?

Jay

On Wed, Nov 10, 2010 at 12:40 PM, David Van Horn<dvanh...@ccs.neu.edu> wrote:
The set library is missing a convenient way of selecting an element from a
set, making it hard to write recursive functions matching the inductive
structure of a set.

Could you add this function, or something like it?

(define (set-choose s)
  (let ((x (for/first ([x (in-set s)])
             x)))
    (values x (set-remove s x))))

David
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev




_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/dev

_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/dev

Reply via email to