Questions tagged as 'haskell'

0
answers

Convert List to Matrix (Haskell)

I am trying to convert a list to an array (list of lists) from a function that receives an Int (i) that is a counter that always starts at 0, another Int (n) that is the length of each row and the list that I have to convert to matrix. crearLd...
asked by 31.10.2018 / 18:29
1
answer

Non-exhaustive patterns error with arrays in Haskell

How are you? I am doing some exercises with Haskell and when compiling the program I get an error as if I were missing a pattern in "cab". I really do not know what it can be. I spent the whole afternoon looking for the error but I can not find...
asked by 28.10.2018 / 00:53
1
answer

Delete an item from a Haskell list

I need help to make a function in haskell in which you have a list and a number and then return the list without the given number Enter [1,2,3,4,4,4,5] 4 Show [1,2,3,5] This way removeElement :: (Eq a) = > [a] - > a - > [a] Gre...
asked by 05.10.2018 / 04:04
1
answer

Compare items from two lists in Haskell

I have tried to compare elements belonging to two lists in Haskell and I do not understand the result obtained. Cito de aprendehaskell.es :    Lists can be compared if the items they contain can be compared. When we use & lt ;, < =,...
asked by 05.09.2018 / 18:29
1
answer

how to do a recursive function in haskell that takes a list of numbers and calculates the average value (truncated, using whole division)?

I have to do the following recursive function, but it throws me error. What's wrong? promedio :: [Int] -> Int, que toma una lista de numeros y calcula el valor pro- medio (truncado, usando division entera). promedio :: [Int] -> Int pro...
asked by 15.08.2018 / 07:55
1
answer

Haskell - Binary tree - Change a variable in a tree to another tree

I have this tree called arb and this other called arbAux and I put a function to replace variable axis: replace Variable "d" arbAux arb then you should change the "d" for the arbAux What I have of code is this typ...
asked by 27.04.2018 / 08:48
0
answers

No instance for (Show (Grafo1 Int)) arising from a use of 'print'

I'm new to Haskell and my problem is to create a graph whose height is a number I give it. The nodes must go from 1 to (2 ^ h) -1 For example. treeFC 0 - > GVacio treeFC 3 - > Arc 3 6 (Arc 3 7 (Node 6 (Node 7 (Arc 2 4 (Arc 2 5 (Node...
asked by 23.01.2018 / 01:25
1
answer

Reading two integers with getLine =

How do I read two numbers from an inputbox in Haskell online with getLine > > = g::Float -> Float -> Float g n t = 2 - (n*t**2+3)) main = getLine >>= (\n -> putStrLn(show (g (read n :: String -> Float))))...
asked by 07.12.2017 / 21:44
1
answer

Read 2 tuples from keyboard in Haskell online

I am using a Haskell compiler online and I would like to be able to read 2 lists of strings from the keyboard (from the input box) two numbers but it throws an error and I do not know how to correct it. f :: [a] -> [[a]] -> [(a,a)] f xs...
asked by 04.12.2017 / 17:43
2
answers

Read 2 values from keyboard in Haskell online

I am using a Haskell compiler online and I would like to be able to read two values from the keyboard (from the input box) two numbers but it throws an error and I do not know how to correct it. g::Float -> Float -> Float g n u = 2 - (...
asked by 03.12.2017 / 22:18