| | |
haskell - displaying contents of a list
Please support our Legacy and Other Languages advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2009
Posts: 7
Reputation:
Solved Threads: 0
I want to write a function that displays the whole contents of a list. But im not sure how to do so. I have displayed my datatype of which i want to print...and at the bottom is the function that I want to print the list with.
Thanks in advance.
- data type
type Title = String
type Director = String
type Year = Int
type Fan = String
data Film = Film Title Director Year [Fan] deriving Show
-- List of films
testDatabase :: [Film]
testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", "Dave", "Zoe"]) ]
--list of films
listFilms :: [Film] -> [Film]
listFilms (film@(Film title director year fans) : films) = putStrLn . show
Thanks in advance.
- data type
type Title = String
type Director = String
type Year = Int
type Fan = String
data Film = Film Title Director Year [Fan] deriving Show
-- List of films
testDatabase :: [Film]
testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", "Dave", "Zoe"]) ]
--list of films
listFilms :: [Film] -> [Film]
listFilms (film@(Film title director year fans) : films) = putStrLn . show
![]() |
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: Haskell IO help
- Next Thread: lex editor
Views: 722 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Legacy and Other Languages





