30 lines
759 B
Haskell
30 lines
759 B
Haskell
deposit value account = account + value
|
|
withdraw value account = account - value
|
|
|
|
eligible :: (Num a,Ord a) => a -> Bool
|
|
eligible account =
|
|
let account1 = deposit 100 account in
|
|
if (account1 < 0)
|
|
then False
|
|
else
|
|
let account2 = withdraw 200 account1 in
|
|
if (account2 < 0)
|
|
then False
|
|
else
|
|
let account3 = deposit 100 account2 in
|
|
if (account3 < 0)
|
|
then False
|
|
else
|
|
let account4 = withdraw 300 account3 in
|
|
if (account4 < 0)
|
|
then False
|
|
else
|
|
let account5 = deposit 1000 account4 in
|
|
if (account5 < 0)
|
|
then False
|
|
else
|
|
True
|
|
|
|
main = do
|
|
print $ eligible 300 -- True
|
|
print $ eligible 299 -- False
|