Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Cartesian product ordering  #37

@marcusps

Description

@marcusps

Although I suppose it is only a matter of convention, it strikes me as unnatural to have product return a sequence that is not in lexicographical order — or rather, the results is lexicographically ordered but from right to left instead of left to right. As the documentation illustrates, the snipped

for p in product(1:3,1:2)
    @show p
end

results in

p = (1,1)
p = (2,1)
p = (3,1)
p = (1,2)
p = (2,2)
p = (3,2)

Other implementations of a cartesian product (in Mathematica and Python) seem to return sequences in left-to-right lexicographical order. The result of the snippet above would then be

p = (1,1)
p = (1,2)
p = (2,1)
p = (2,2)
p = (3,1)
p = (3,2)

Is there a deeper motivation for the right-to-left choice that is currently implemented?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions