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 = [(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 buscarDB
function, which would work like this:
Entry: buscarDB 1006
Output: ("Feijao", 780)
This function would use buscarBDaux
, but I'm not able to call buscarBDaux
without having passed the database in buscarDB
. Could you help me?