20 videos
111 minutes
Hello world as they are, my name is Joseph and I welcome this new course haskell tutorial. That is we are doing and today we will see lists. If you remember in a previous video we saw that, haskell has implemented some lists default so that for example You could call the functions for use by, examples has a list of two numbers has a list of letters,
then if I here give the following number 7 gave me 8 if digests to give me the number after the letter c d turn gives me the lists are already They were created by default, but as I can do to store data lists first thing to know is that in the data list should not mix data. I will create a list that tells me [5,2,6,9] separated by commas but here I put a letter, then tells me that you can not mix data
then to work with the first list, it is that it has to be the same thing now if I want to add two lists to keep them all together We no longer saw to concatenate strings have to use the ++ operator here I put 'hello' + 'world' does not work for me, but if I put 'hello' ++ 'world' for there if you understand well then that it happens because the chains are considered ready so when I put the ++ is concatenated me
because I considered actually list a string 'hello' really you understand what is this haskell [ 'h', 'o', 'l', 'a'] there saw 'hello' so a string It is like a list where each list items is actually an individual character letter by letter, so when I put ++ is concatenated. So if I create a list here [5.1.2] and I want to get to this list more items and here I put [5.1.2] ++ [8,9], then there is no problem
but here I say the list has [3,4,9] and say that that list will add 2, fails because a list will not have to put numbers lists. So here what I have to do and put some numbers if I have a list [5,2,3] you want to put a 7 what I have to do is put the 7 like a list [5.1.2] ++ [7] so that would be a list of one element but it is a list, but I can combine lists and lists,
but not numbered lists but now I put [5,1,2,7] and there is no problem there saw works now happens if I want to do with letters, it is exactly the same if I have a list here that has [ 'h', 'or'] ++ [ 'l', 'a'] and there is no problem 'hello' saw there. Well there is another way to add lists combine with the operator: if I here want to concatenate a list 59 to 59 put it well: [1,2]
and there he put it to me first of all [59,1,2] and now the same happens with the letters here if I want to put the 'h' I put: 'ola world' for me concatenated 'hello world' and the order in which the sum is the same order as me is what the character indicating first and then the rest of the chain good I saw and make the 'H' test 'world wave' if put in quotes fails, because this list what you have inside are characters
by chains characters are considered then as a list of characters you have to put a character and characters do not go with double quotes ( '') but with single quotes ( '') understand the idea then do with single quotes, if because this is actually a separate list of characters with single quotes so to put double quotation mark,
not because it is as if we mix a string into a list of characters. OK good because this is a bit the idea of lists and the next video let's see features that brings haskell default to manage lists. So I hope you are enjoying it can give like, subscribe, share and see you in more video
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.