[racket] Take an element from a set

From: Rodolfo Carvalho (rhcarvalho at gmail.com)
Date: Wed Sep 7 23:16:11 EDT 2011

Hello,

I'm trying to take an arbitrary item from a set, but I couldn't find a
documented way to do so.
I'd have something like this for example:

> (set-item (set 2 1 3))
3


The best implementation I could come up with for set-item is:

; return one arbitrary item of the set
;
; set -> any/c
(define (set-item s)
  (for/first ([item (in-set s)]) item))


Would anyone recommend better ways?

Thanks,

Rodolfo Carvalho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110908/63e0c597/attachment.html>

Posted on the users mailing list.