zip() function

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

zip() function

Message par compsystems » jeu. mars 28, 2019 12:13 am

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]]

parisse
Messages : 5743
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: zip() function

Message par parisse » jeu. mars 28, 2019 6:01 am

I disagree, it's better to have an error if the list dimensions do not match, this way debugging programs is easier.

Répondre