Haskell

Haskell 11: Infinite functions Lists

20 videos

111 minutes

Hello world how are you? My name is Joseph and I welcome this course Haskell tutorial where we will see functions for lists which become infinite, then good, there are some features that might seem a little ridiculous or make little sense, for example, repeat function if I here make a repeat and I put a number, for example, then I will repeat that number constantly, not infinitely;

but such functions for some cases can be useful, no. The thing is that at least we have seen a function, the repeat. Then we also have another function here, which is the 'cycle' function, and this function does is repeat indefinitely the list that we you say; for example, if I here are a list of: 2, 4, 6, as that list is constantly repeating the saw, an infinite list is created.

There is also the replicate function, no, here it is repeated as many times as I say, if I want to repeat five times the number 60, because there you have it, 5 times, no. Then I also can tell you that repeated twice, instead of a number I can tell you that a number be repeated; for example, the series to recur, the h and o. For now, twice me those two letters, those two chains, these twice; with the option to replicate. And finally,

perhaps, to manage all these lists and not have to draw on the screen; the entire screen, fill me the data, it can use a function call, which we have already seen in the last video, which is the take function; so, for example, I do this: I do a take and take four numbers, and here I have to put the function, the function to tell me, for example, repeat 3 because I will leave that way. But if I here you say,

give me the first four numbers of the 'cycle' hello, hello gives me only; but I say hello world, only gives me hello because it stays with the first four; but if I tell you here, instead of four, give me eighty, because I believe different worlds hellos and short in the last eighty, Well, that happened just caught that matches; but if I want to divide a space that differs me, a chain from another, they saw that separated me.

Then, well, these are examples that do not have much sense, but the thing is what each function, so already there, you can apply the for what interests you. Then, as they saw that, with the function they already knew, with take, because there already be cut, a little, until some want arrive. After the repeat, repeat indefinitely; to replicate, you stipulate how many repetitions want to be made of a chain or

a number and function 'cycle', cycle this, you then repeat indefinitely both a number and a string; the thing is already there, they can get the amount you interested, with take or drop also, as we saw earlier; if I put drop and give of cycle, hello, and drop I say that the first letters cut me, do not give me; ah, I did not put the quotes of the end; because I get all because short drop only the beginning

and the end leaves it, all I get, but the end; but surely the first twenty, twenty first, which would be these; take 20 cycle hi, these twenty, not pulled me, took me from the following. you already know the difference of take and drop, which saw the last video. Well, I hope you will be enjoying videos and here and saw different functions for infinite lists, so they can give like,

share or subscribe. And 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.