Haskell

Haskell 14: VS tuples Lists

20 videos

111 minutes

Hello world how are they? I welcome this new video course Haskell, we are doing and this time; we will see the difference, from a list, which we have analyzed in several videos of lists and that is a tuple. So here, first I explained is a tuple. A tuple: is the collection of data, the data set that we will have, but differs from a list, because a tuple can mix data types,

for example, if you had a list here and wanted to do the following, with brackets, I wanted to do: 1, 2; there was no problem, but if you wanted to mix numbers with strings, gave me error, right? Well, tuples, this does not happen. If I believe a Dupla here, the difference is that in the Duplas They are made with the brackets, not the brackets and I do so, I do believe, 1, 2; there is no problem, but if I put a string here,

there is no problem, so with the Duplas allow mixing types within the elements that go to have. Well, now, this is a differences more powerful, which gives the Dupla a value on the lists; but there when we make lists of lists, sets of lists of lists and Duplas lists; well, a list of lists, if I put here, for example, did so; I'll put here Superlist, to call

somehow. I could have, within this list several lists, right ?, as we already knew, right ?, separated by commas and then here could do, for example, excuse me, now ... now, excuse me, I could put this, here I could put two elements, then here I can put four elements and here, Finally, if I want, I could put three elements, right? And there is no problem, the lists of lists, there may be different types of sizes

lists that form the Superlist and there is no problem. There may be a list of two elements, one with four and one with three and well. With Duplas, no. If I make a list here Duplas, for example, here is a list of Duplas; put here the list that will have the Duplas and of course the Duplas and would put so with their brackets and now here, if I put 1, 2; here I put, 3, 4 and here put, 5, 6;

no problem, because all have the same size, but if you resize some, give me error. So here this is very important, not all Duplas, when they belong to the same list, they must have all the same size. What about the guy ?, therefore have to have all the same structure, for example, here, if I put six gives me an error; because, see, sorry, I'll clean, well ... because it gives me error because because not all; not all

elements keep the same pattern and that is important. If I here to this, in this case, put two and here put four letters. I'm already doing all the Duplas are, a number and a string; a number and a string. And keep that pattern, if I give you this, so there is no problem, they saw. So this is also important to keep this in mind, right? That when they make lists Duplas have to have all the same format

and the same size. Okay? Well, these are the tuples of two elements; tuples of two elements Duplas calls. If we Duplas three elements would triples, if we had, tuples of four elements, would quadruple and five, Quintruplas, well, anyway; and it would be the nomenclature that you can imagine. The important thing is to remember this: A tuple can combine different types of items and lists

of Duplas, they must have, all the same size and all of the same format. We could also make a list of triples, for example, here, a list of triples in which, of course, and can, because here we would have to put another element, but remember, always keeping the format, come; there is no problem. I, only here it would have changed, and fails because it does not maintain the same format. Well these are different than

as there are lists and tuples. In the following video, we will see other functions that are special to tuples. So here, I hope you liked it, you can give like, share or subscribe. See more videos. A greeting.

To find new courses, subscribe. There will be no spam, promised :)

About the Author

foto de jotajotavm
José Javier Villena

Biography: Analyst-Programmer in different languages. Tutor PREMIUM platforms recognized worldwide as CodigoFacilito. Editor Cristalab articles. My YouTube Channel is sponsored by the ANAYA and LaTostadora publisher. I like to explain in detail and give several examples for the avoidance of doubt.