StdOrdList.dcl 1.43 KB
 Thomas van Noort committed Oct 07, 2010 1 2 ``````definition module StdOrdList `````` Camil Staps committed Jun 22, 2020 3 4 5 6 ``````/** * Functions to work with lists of elements for which an ordering exists. */ `````` Thomas van Noort committed Oct 07, 2010 7 8 9 10 11 12 13 ``````// **************************************************************************************** // Concurrent Clean Standard Library Module Version 2.0 // Copyright 1998 University of Nijmegen // **************************************************************************************** import StdClass `````` Camil Staps committed Jun 22, 2020 14 15 ``````//* Sort a list (mergesort). sort :: !u:[a] -> u:[a] | Ord a `````` Thomas van Noort committed Oct 07, 2010 16 17 18 19 `````` special a = Char a = Int a = Real `````` Camil Staps committed Jun 22, 2020 20 21 22 23 24 25 26 27 28 `````` /** * Sort a list using a custom ordering. * @param The custom {{`<`}} function */ sortBy :: (a a -> Bool) !u:[a] -> u:[a] //* Merge two sorted lists. merge :: !u:[a] !v:[a] -> w:[a] | Ord a,[u v <= w] `````` Thomas van Noort committed Oct 07, 2010 29 30 31 32 `````` special a = Char a = Int a = Real `````` Camil Staps committed Jun 22, 2020 33 34 35 36 37 38 39 40 41 `````` /** * Merge two sorted lists using a custom ordering. * @param The custom {{`<`}} function */ mergeBy :: (a a -> Bool) !u:[a] !v:[a] -> w:[a],[u v <= w] //* The maximum element of a list. maxList :: !.[a] -> a | Ord a `````` Thomas van Noort committed Oct 07, 2010 42 43 44 45 `````` special a = Char a = Int a = Real `````` Camil Staps committed Jun 22, 2020 46 47 48 49 50 51 52 53 54 `````` /** * The maximum element of a list using a custom ordering. * @param The custom {{`<`}} function */ maxListBy :: (a a -> Bool) !.[a] -> a //* The minimum element of a list. minList :: !.[a] -> a | Ord a `````` Thomas van Noort committed Oct 07, 2010 55 56 57 58 `````` special a = Char a = Int a = Real `````` Camil Staps committed Jun 22, 2020 59 60 61 62 63 ``````/** * The minimum element of a list using a custom ordering. * @param The custom {{`<`}} function */ minListBy :: (a a -> Bool) !.[a] -> a``````