Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; https://stackoverflow.com/questions/60076982/
- ;; i-want-to-make-a-function-that-deletes-only-a-single-minimum-element-in-a-list
- deleteMin [] = []
- deleteMin (x:xs) = if (imin==0) then xs else (x:ys)
- where
- (ys, imin) = foldr g z xs 1 (0 :: Int) x
- where
- z _ im _ = ([], im)
- g x r !i !im !xm = (if (i == imin) then ys else (x:ys), im')
- where
- (ys, im') | x < xm = r (i + 1) i x
- | otherwise = r (i + 1) im xm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement