ex8, whileRight done

This commit is contained in:
Aaro Koivukangas
2024-01-13 11:28:27 +02:00
parent 550352c93e
commit 707706fdfc
+3 -1
View File
@@ -169,7 +169,9 @@ while check update value = if check value then while check update (update value)
-- Hint! Remember the case-of expression from lecture 2.
whileRight :: (a -> Either b a) -> a -> b
whileRight check x = todo
whileRight check x = case check x of
Left value -> value
Right x -> whileRight check x
-- for the whileRight examples:
-- step k x doubles x if it's less than k