Created
October 25, 2010 16:51
-
-
Save jutememo/645292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 $ | |
[p | p <- persons | |
, all (\g -> exists [a | a <- assignments | |
, a_g_id a == g_id g | |
, a_p_id a == p_id p]) | |
groups] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment