0
I’m trying to solve some basic Haskell problems, 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 = [(1001,"Refrigerante",450),
(1002,"Leite",320),
(1003,"Biscoito",200),
(1004,"Suco",989),
(1005,"Arroz",345),
(1006,"Feijao",780)]
buscarBDaux:: CodigoBarra->BancoDeDados->(Nome,Preco)
buscarBDaux cd ((a,b,c):d) |a == cd = (b,c)
|otherwise = buscarBDaux cd d
Now I need to implement the function buscarDB
,that would work like this:
Entree: buscarDB 1006
Exit: ("Feijao", 780)
This function would use the buscarBDaux
, but I’m not able to call buscarBDaux
without having passed the database on buscarDB
. Could you help me?
Thanks for the help luispauloml, solved my problem.
– Gustavo Cruz