Open apblack opened 7 years ago
Sure. Too bad there are no built in tuples, as it makes more sense to give the result as a list of pairs.
I'll let you speculate on what the type of zip should be (if we can't write a good type, perhaps we shouldn't put the function into the library).
Or we can fight over what square brackets should mean. Again.
(Actually, if we really stick to our guns on being "OO" rather than "functional", abstract rather than concrete, co-algebraic rather than algebraic - then writing tuple(x,y) ain't so bad. (Though I'm tempted to spell "tuple" as "data")
Unfortunately we can no longer deconstruct such things in matches.
As I defined it with my single example,
type List⟦X⟧ = {
...
zip(o:List⟦Y⟧) -> List ⟦ List⟦X|Y⟧ ⟧
...
}
but it might be more reasonable to have it return a list of bindings:
type List⟦X⟧ = {
...
zip(o:List⟦Y⟧) -> List ⟦ Binding⟦X, Y⟧ ⟧
...
}
yes. bindings stand in for 2-tuples - J
On 8/06/2017, at 12:21PM, Andrew Black notifications@github.com wrote:
but it might be more reasonable to have it returns list of bindings:
Should we add a
zip(_)
method to Enumerables?