Questions tagged as 'haskell'

1
answer

Doubt in the case of Stop

listasIguais :: (Eq a) => [a] -> [a] -> Bool listasIguais [] p = False listasIguais p [] = False listasIguais (x: xs) (y:ys) = x == y && (listasIguais xs ys) listasIguais [(2,4),(4,6),(8,9)] [(1,4),(2,6),(4,9)] False This...
asked by 25.12.2017 / 14:46
0
answers

Input and Output - Definition

What is the definition of the following predefined functions of System.Random :: a) randomRIO :: (Int,Int)-> IO Int b) putChar :: Char -> IO ()     
asked by 12.12.2017 / 00:14
1
answer

Haskell - Higher Order Functions

(a) any :: (a -> Bool) -> [a] -> Bool that tests whether a predicate is true for some element of a list; for example: any odd [1..10] == True (b) zipWith :: (a->b->c) -> [a] -> [b] -> [c] which combines the elem...
asked by 14.11.2017 / 00:18
1
answer

Recursive definition of the predefined function EnumFromThenTo

How to recursively define the EnumFromThenTo function     
asked by 30.10.2017 / 18:51
1
answer

Positioning an element in the list

Well, I had to do a function that, given a list and a number, returns the list element that is in that position (the number). Basically it is the function already defined. The problem is that I have to restrict the function in case the given...
asked by 07.10.2017 / 22:25
1
answer

Haskell- Replace function in a list

They know if there is a predefined function in the haskell that gives an element, it replaces it with another element of a certain position in the list. For example: func 1 2 [1,2,3,4] [1,2,1,4]     
asked by 23.10.2017 / 09:26
1
answer

How to call an auxiliary function without passing the parameter through the main function

I'm trying to solve some basic haskell issues, but I'm having a hard time. I implemented the following code: type Nome = String type Preco = Int type CodigoBarra = Int type BancoDeDados = [(CodigoBarra, Nome, Preco)] bd:: BancoDeDados bd = [(...
asked by 24.02.2018 / 12:38
1
answer

Problems with instance list in Haskell

I have a job on the facu and I get this error:    'decide' is not a (visible) method of class 'Char' for the code below: data Paridade = Par | Impar deriving Show class ParImpar a where decide :: a -> Paridade instance ParImpar...
asked by 29.03.2017 / 20:45
1
answer

Tree Transformation

Considering the structures: data BTree a = Empty | Node a (BTree a) (BTree a) data LTree a = Tip a | Fork (LTree a) (LTree a) data FTree a b = Leaf b | No a (FTree a b) (FTree a b) Set the splitFTree :: FTree a b -> (BTree a, LTree b)...
asked by 02.12.2017 / 21:13
1
answer

Junction of trees - joinTree

data BTree a = Empty | Node a (BTree a) (BTree a) data LTree a = Tip a | Fork (LTree a) (LTree a) data FTree a b = Leaf b | No a (FTree a b) (FTree a b) Set the joinTrees :: BTree function to - > LTree b - > Maybe (FTree a b) that whenev...
asked by 03.12.2017 / 18:05