lazy thoughts

Daniel Keep daniel.keep.lists at gmail.com
Mon Jan 12 18:39:50 PST 2009


Andrei Alexandrescu wrote:
> Bill Baxter wrote:
>> [snip]
>>
>> Another commonly used func from Python is zip().  Not sure if that one
>> is doable in D because it relies heavily on Python's tuples to work,
>> but in Python it offers a very clean solution to iterating over
>> several lists at once.
>>      for xy in zip([1,2,3],[4,5,6]):
>>         # xy gets sequence of tuples (1,4), (2,5), (3,6)
>>
>>      for x,y in zip([1,2,3],[4,5,6]):
>>         # tuple split into x and y automaticallly
> 
> zip() is absolutely on the list.

How are you going to implement zip?  I tried writing a version ages ago,
and the issue I ran into is that you cannot support any user-defined
iterables with it.

The problem is that opApply uses inversion of control to do its work, so
you can't run more than one opApply in lockstep unless you're using some
form of threading.

In a more general note, this is all shaping up to be incredibly awesome;
keep up the good work! :D

  -- Daniel



More information about the Digitalmars-d mailing list