IntegratedDynamics icon indicating copy to clipboard operation
IntegratedDynamics copied to clipboard

Add a zip operator

Open hnOsmium0001 opened this issue 6 years ago • 3 comments

Issue type:

  • :heavy_plus_sign: Feature request

Short description:

Add a zip function that works like the one from Python, which takes several lists and combines them to a list of lists containing elements from the same index. For example zip([1,2,3,4],[20,19,18,17]) returns [[1,20],[2,19],[3,18],[4,17]]

hnOsmium0001 avatar May 28 '19 00:05 hnOsmium0001

I don't like the implied type signature of this operator. I'd rather see one of two alternatives:

  1. transpose([[1,2,3,4],[20,19,18,17]]) returns [[1,20],[2,19],[3,18],[4,17]]
  2. zip([1,2,3,4],[20,19,18,17]) returns [(1,20),(2,19),(3,18),(4,17)] (requires that we add tuple types)

josephcsible avatar Jun 15 '19 15:06 josephcsible

... requires that we add tuple types

I don't personally think that it is worth adding tuple types just for the sake of the type signature. If we have more than just this reason, great, but it seems overkill just for a fixed-length list

Alpvax avatar Jun 18 '19 16:06 Alpvax

I have indeed occasionally wanted tuple types for other reasons.

josephcsible avatar Jul 04 '19 05:07 josephcsible