search - Haskell: looking up the second value of a tuple in a list based on the first value -


I have found a function here which means to see the list of tuepels and the second value in the Tuplicate first assumption here. Has yet:

  lookup :: string - & gt; [(String, string)] - & gt; String lookup _ _ [] = "not found" lookup xy zs = if (notFound x zs) then "not found" and second (head [b (a, b) <- zs, (a == x) ])  

The notfound function returns only one bull as the truth if there is no first-class tubal. The problem is, I get this kind of error in Hog:

  error "Search. Hs" (line 22): Type Binding type type error *** Duration: Lookup *** Type: String - & gt; [(String, string)] - & gt; [A] - & gt; String *** is not a match: string - & gt; [(String, string)] - & gt; String  

I think there is something with a dummy that has a different "type" not found in the string from the generated list, but I'm not sure.

I think your clear-cut declaration is wrong: you have

  Lookup :: String - & gt; [(String, string)] - & gt; String  

but I think it should be

  lookup :: string - & gt; String - & gt; [(String, string)] - & gt; String  

Actually, after taking another look at it, it seems that if you are not using 2 parameters "y" then you can remove it and thus underscore

  Lookup :: string - & gt; [(String, string)] - & gt; String lookup _ [] = "not found" lookup x zs = if (notFound x zs) then "not found" second (head [b | (a, b)] - zs, (a == x)])  

This will allow you to keep your type of announcement.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -