-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lab3 Rudnevskiy #10
base: master
Are you sure you want to change the base?
Lab3 Rudnevskiy #10
Conversation
(==) = undefined | ||
(==) (P a) (P b) = checkNull a == checkNull b where | ||
checkNull [] = [] | ||
checkNull lst = if (last lst == 0) then checkNull (init lst) else lst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это очень неэффективная реализация из-за медленных last
и init
, но ладно.
it "xor" $ do | ||
xor True True `shouldBe` False | ||
xor True False `shouldBe` True | ||
xor False True `shouldBe` True | ||
xor False False `shouldBe` False | ||
it "geomProgression" $ do | ||
geomProgression 5.0 0.5 2 `shouldBe` 1.25 | ||
geomProgression 5.0 2.0 3 `shouldBe` 40.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Функции добавили и QuickCheck раскомментировали, но тесты-то без QuickCheck! Из-за своей задержки я поставлю полный балл с возможностью его увеличить, добавив тесты в QuickCheck.
{- -O0: Total time: ??? Total Memory in use: ??? -} | ||
{- -O2: Total time: ??? Total Memory in use: ??? -} | ||
minMax = undefined | ||
minMax [] = Nothing | ||
minMax (x:xs) = Just (foldl update (x, x) xs) where | ||
update (minVal, maxVal) current = (min minVal current, max maxVal current) | ||
|
||
-- Дополнительное задание: реализуйте ту же самую функцию (под названием minMaxBang) с | ||
-- использованием явной строгости (seq и/или !) | ||
|
||
{- -O0: Total time: ??? Total Memory in use: ??? -} | ||
{- -O2: Total time: ??? Total Memory in use: ??? -} | ||
minMaxBang = undefined | ||
minMaxBang [] = Nothing | ||
minMaxBang (x:xs) = Just (foldl (\(mn, mx) y -> (min mn y, max mx y)) (x, x) xs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это та же реализация, что выше, только с другими названиями переменных, без seq
и без !
.
Тут замечания есть, но я поставлю полные баллы за 2 и 3 лабораторные, и при исправлении можно ещё увеличить. |
No description provided.