#11255: Enhance the e_one_star.Patch class
-----------------------------+----------------------------------------------
   Reporter:  tjolivet       |          Owner:  sage-combinat
       Type:  enhancement    |         Status:  needs_review 
   Priority:  major          |      Milestone:  sage-4.7.1   
  Component:  combinatorics  |       Keywords:               
Work_issues:                 |       Upstream:  N/A          
   Reviewer:                 |         Author:  Timo Jolivet 
     Merged:                 |   Dependencies:               
-----------------------------+----------------------------------------------

Comment(by slabbe):

 > The only thing that bugs me is that we have to create a whole iterable
 to pick a single element of a Patch: the best way I can think of is
 {{{list(P)[0]}}}. Using {{{random.choice}}} is of course overkill, and
 there is no {{{frozenst.pick_arbitrary}}} method (which would be nice...).

 To get the first element, you can do:

 {{{
 sage: S = set(range(10))
 sage: next(iter(S))     # or equivalently: iter(S).next()
 0
 }}}

 To get the i-th element:

 {{{
 sage: from itertools import islice
 sage: next(islice(iter(S), 7, None))
 7
 }}}

 I look at your patch and review it soon. Je crois bien qu'on y est
 maintenant!

 Sébastien

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11255#comment:17>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to