Page 1 sur 1

zip() function

Publié : jeu. mars 28, 2019 12:13 am
par compsystems
Hello

zip iterates over the dimension of the least argument

zip('+',[a,b,c,d], [1,2,3]) > [a+1,b+2,c+3]
zip('+',[a,b,c], [1,2,3,4]) > [a+1,b+2,c+3]

strList := ["one", "two","three"]
numbersList := [1, 2, 3]
result = zip(strList,numbersList) >
[["one",1],
["two",2],
["three",3]]

but in the following case it generates an error
strList := ["one", "two"]
numbersList := [1, 2, 3]
result = zip(strList,numbersList) > "Error"

expected
[["one",1],
["two",2]]

Re: zip() function

Publié : jeu. mars 28, 2019 6:01 am
par parisse
I disagree, it's better to have an error if the list dimensions do not match, this way debugging programs is easier.