Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created October 25, 2010 16:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jutememo/645292 to your computer and use it in GitHub Desktop.
import Data.Time.Calendar
data Person = P { p_id :: Int
, name :: String
, gender :: Int
, age :: Int
} deriving (Show, Eq)
data Group = G { g_id :: Int
, gname :: String
} deriving Show
data Assginment = A { a_id :: Int
, a_p_id :: Int
, a_g_id :: Int
, date :: Day
} deriving Show
persons = [ P 1 "Tarou" 1 10
, P 2 "Hanako" 2 20
, P 3 "Jirou" 1 30
, P 4 "Saburou" 1 40
, P 5 "Akemi" 2 8
, P 6 "Sadayo" 2 70
, P 7 "Hiroko" 2 15]
groups = [ G 1 "Matu", G 2 "Take", G 3 "Ume"]
assignments = [ A 1 1 1 (fromGregorian 2010 4 1)
, A 2 2 1 (fromGregorian 2009 9 1)
, A 3 3 2 (fromGregorian 2010 4 1)
, A 4 1 2 (fromGregorian 2010 5 1)
, A 5 1 3 (fromGregorian 2011 4 1)]
exists = not . null
main = print $
[p1 | p1 <- persons
, age p1 == maximum [age p2 | p2 <- persons
, gender p2 == gender p1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment