Commit 5c44c93f authored by Steffen Michels's avatar Steffen Michels

add Data.OrdList

parent c28cd6c8
Pipeline #8758 passed with stage
in 1 minute and 30 seconds
definition module Data.OrdList
/** This module extends StdOrdList with extra functions.
*/
import StdOrdList
/** removeMembersSortedList @xs @ys = @zs:
removes all occurrences of elements in @ys from @xs, resulting in @zs.
The function assumes that both @xs and @ys are sorted and contain no duplicate elements.
*/
removeMembersSortedList :: ![a] ![a] -> [a] | Eq, Ord a
/** removeDupSortedList @xs = @zs:
removes all duplicate elements from @xs, resulting in @zs.
The function assumes that @xs is sorted.
*/
removeDupSortedList :: ![a] -> [a] | Eq a
implementation module Data.OrdList
import StdList, StdOrdList
/** removeMembersSortedList @xs @ys = @zs:
removes all occurrences of elements in @ys from @xs, resulting in @zs.
The function assumes that both @xs and @ys are sorted and contain no duplicate elements.
*/
removeMembersSortedList :: ![a] ![a] -> [a] | Eq, Ord a
removeMembersSortedList [] ys
= []
removeMembersSortedList xs []
= xs
removeMembersSortedList [x:xs] [y:ys]
| x < y = [x : removeMembersSortedList xs [y:ys]]
| x == y = removeMembersSortedList xs ys
| otherwise = removeMembersSortedList [x:xs] ys
/** removeDupSortedList @xs = @zs:
removes all duplicate elements from @xs, resulting in @zs.
The function assumes that @xs is sorted.
*/
removeDupSortedList :: ![a] -> [a] | Eq a
removeDupSortedList []
= []
removeDupSortedList [x:xs]
= [x : removeDupSortedList (dropWhile ((==) x) xs)]
...@@ -81,6 +81,7 @@ import qualified Data.Integer.Mul ...@@ -81,6 +81,7 @@ import qualified Data.Integer.Mul
import qualified Data.Integer.ToInteger import qualified Data.Integer.ToInteger
import qualified Data.Integer.ToString import qualified Data.Integer.ToString
import qualified Data.List import qualified Data.List
import qualified Data.OrdList
import qualified Data.Map import qualified Data.Map
import qualified Data.Matrix import qualified Data.Matrix
import qualified Data.Maybe import qualified Data.Maybe
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment