#19319: iterator over pairs on diagonals a la Cantor pairing
-------------------------------------+-------------------------------------
Reporter: dkrenn | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.9
Component: misc | Resolution:
Keywords: | Merged in:
Authors: Daniel Krenn, | Reviewers: Daniel Krenn
Clemens Heuberger | Work issues:
Report Upstream: N/A | Commit:
Branch: | fde8e6d09f41645ec4faf9d071cf60c7b35ef9e3
u/dkrenn/product_cantor_pairing | Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by cheuberg):
Replying to [comment:31 vdelecroix]:
> Replying to [comment:30 cheuberg]:
> > Iteration over the product of n iterators will, as far as I can see,
always need some recursive algorithm. I do not know whether avoiding
iterators internally would make that much of a difference with respect of
speed; IMHO it will not make it more readable.
>
> Nope. If you look at the code of `product` in Python there is no
recursion involved. It 70 lines long, with a lot of spaces and written in
pure C.
for infinite iterators, I suppose that things get somewhat trickier.
> > What about replacing `product_cantor_pairing(A, B)` by
`product_cantor_pairing([A, B])` and implementing products of `>= 3`
iterators by a recursive call to `product_cantor_pairing` (and flattening
the results) for the time being?
>
> Is that the canonical order you want for a triple?
Well, I am not really eager for ordering triples anyway.
But I imagine that having
`product_cantor_pairing([A, B, C])` returning the elements in the same
order as
`product_cantor_pairing([product_cantor_pairing([A, B]), C])` (or the
other way around, i.e., `product_cantor_pairing([A,
product_cantor_pairing([B, C])])`) would make sense.
--
Ticket URL: <http://trac.sagemath.org/ticket/19319#comment:32>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.