Haskell Map definition Error -


I am recently for Haskell and I have a problem while trying to write my definition of the map function. Example: Mapi (& gt; 2) [1,2,3,4,5] = [false, false, true, true]

  Mapi _ [] = 0 mpeg F (X : Xs) = [fx] ++ mapi f xs   

When I try this I get an error:

  any number (number [bool] ]]) Potential Fix: Potential Fix: (Name [Child]) Add an example announcement for: Mapi (> 2) [1, 2, 3, 4, ...] Equation for `this': this = mpei (& gt; 2) [1, 2, 3, ....]   

I know that it is related: mapi _ [ ] = 0 but I do not know the problem I found it, I mean, he has to stop at []!

You accidentally replaced 0 with [] In the first case it should be

  mapi _ [] = [] mpeg f (x: x) = [fx] ++ mpeg fx   

If you type a signature, it helps:

  mapi :: (a-> b) - & gt; [A] - & gt; [B]   

then Mapi is considered to return the function, a list, and a list 0 is not a list Is, but [] is.

Any example ....

The error message is saying that this will be done in 0 in a [bool] It was trying to change, which is not it a numerical type, it is stuck because the Num class by fromInteger function, but [bool] . (Each Num example should have a to the integer function so that the written words containing the integers like 0 and 23 That type of value can stand for.)

This shows that you can make an example for Num [Bool] so that it can be compiled. This is not a good idea, and this particular error message is often due to a type of mismatch rather than an actual example example - it is worth remembering next time.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -