[racket] Take an element from a set

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Wed Sep 7 23:36:32 EDT 2011

This looks like a reasonable way to get an element, but thinking
ahead, you will probably want something both like "first" (which you
have) and a corresponding "rest".

The problem is that which element you get from the "first" operation
is nondetermistic in a set.  Therefore, you have to either

- pass the returned first element to the rest operation, or

- accept that
  (set-union (set (set-item S)) (set-rest S))
  is not the same as S

A better design would be to use a different signature:

  get-one/rest : (forall (A) (Set A) -> (values A (Set A)))

This performs the split "atomically", so it can ensure that the
combination of "one" and "rest" is the same as the original set.


Posted on the users mailing list.