He guys,
My task is to program a phonebook in Haskell. Therefore type Phonebook is given. The Phonebook maps names(String) to their phone numbers(String). But now I have problems implementing the function 'insert':
Heres the code:
type Phonebook = String -> String
emptyPhonebook :: Phonebook
emptyPhonebook = \_->""
insert :: String -> String -> Phonebook -> Phonebook
insert name number emptyPhonebook = (
ame->number) --is this correct?
insert name number existingPhonebook = ??
My question: How do I insert a function in a function? I mean now I have to insert an entry consisting of a function (name -> number) in another function (existing Phonebook) or am I wrong? Thanks for helping me out :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…