20 videos
111 minutes
Hello world how are you? My name is Joseph and I welcome this new tutorial course Haskell and this time we will see a bit ranges that we can use in our lists, that is, if for example we want on our list have all the numbers, for example, there is even or all odd from 1 to 100, it would be very complicated,
So let itself started writing the same list and now with brackets, and started putting all even numbers up to 100, for example, no, it would be very difficult, then, as we do in Haskell, because in Haskell; there is a system of 'mini-intelligence' serving for the compiler understands, that is what we are; that list we want to generate.
We just have to spend the first two numbers of the list and it automatically interprets the rest. For example, if I want to put all the even numbers would read: 2, 4. Only that and then two points and to where I want you generate, for example, I want to be up to 100, for example. Yes now. It is done. And Haskell knows that, I know all the numbers 2 to 2.
So I am ready and I get all even numbers, there is from 2 to 100, that is the limit that I have made him. So, if I say here that the limit is 103, because then I will be up to 102, because after 103 does not advance. Sure, but, the thing is this, Haskell interprets it as a difference of sum;
if I want, instead of it 2 by 2, I want to be the powers of two; for example, I want you here gives me 2, 4, 8, 16 ... and I do so up to 100 for example, fails me; because I can only spend 2 parameters, two, just two Then, as Haskell knows if what I want is me by joining two go and give me two at a time or if what I want is multiplicándome in twos.
Well that Haskell can not know and we can not give a number of parameters so that, as if we will tell tracks, no. Haskell making, which by default, consider the relationship of each other, always as addition or subtraction; so yeah here I gave him a two-and-a Four here what I do is add two and two and I will continue giving sums of consecutive twos,
which they are what we have here; As with any number, yes here you get ready and start with one and then give him seven, so until the thirty-four, for example, which actually is to add six, so I will say that after seven plus six plus six thirteen and nineteen; if I run it is what we have there, one, seven, nineteen and goes every six, that's the difference.
Similarly, also in reverse, if you put me here and I want to list here the numbers from one hundred, going down I fives, to zero, because I'll be there all numbers, fives; because the difference in this issue to this are least five, so from there I subtracted five, no, until it reaches zero. All right. That is the way to create lists without putting all the numbers,
also this works for me letters; yes I put the list here and I want the letters a and go jumping me a yes and no, and I put: it would be A to B, no, c, yes, it assumes that the following is the c, so to z. Well then, I now leave the letters, but skipped; they saw the a, b, c no, yes the d, no, and, yes; one yes and no, which is the sequence I have given.
With a difference and a jump letter. Of course, if what I want is that I leave all, because then I have to do, I'm here to clean the screen then I have to do is simply put the first and last, and Haskell and understand what that means, if I put here, one and I say to eighty, then I will give all the numbers from one to eighty, one by one, they saw.
Similarly, with ... well and this gives like set from the one, I start in the seventh; seven up to thirty-seven; hey, sorry, I miss you so equal; and now I will give it one by one; not, because when I say nothing, goes one on one, so the sequence goes to the thirty-seven. Same with the lyrics, if I here you do with letters and I want to go from a to h,
say for example, because there I have, all the letters; same with the case, I can put from V and J until now; Oh, sorry, I have to put the two points; I made a list of two elements, now there I have all uppercase, JKLMN, as such as they are in the alphabet. Well, this has been the tutorial this time, we have seen how to apply ranges to creations of lists
and for the next tutorial we will see some issues that have to do with infinite lists; that is, if I here think me a list, but I do not tell him until number; I leave it open, the list is endless, no, if I here want the multiples of three and say 3, 6, dot, dot and I say nothing, believe it and now when I give a show, I get all three numbers multiples not; I'm going to give here the pause and stops,
and well, I was the beginning, but we'll see, we take this, no; It is adding three; 47, 50, 53, 56, there are infinite lists, no. So that, in the next tutorial we will see how to manage it and so I hope that this liking you. They can give you like, share or subscribe and send a greeting.
About the Author
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.