StdOrdList.dcl 1.46 KB
Newer Older
1 2
definition module StdOrdList

Camil Staps's avatar
Camil Staps committed
3 4 5 6
/**
 * Functions to work with lists of elements for which an ordering exists.
 */

7 8 9 10 11 12 13
//	****************************************************************************************
//	Concurrent Clean Standard Library Module Version 2.0
//	Copyright 1998 University of Nijmegen
//	****************************************************************************************

import StdClass

14 15 16 17
/**
 * Sort a list (mergesort).
 */
sort    ::               !u:[a] -> u:[a] | Ord a
18 19 20 21
	special
		a	= Char
		a	= Int
		a	= Real
22 23 24 25 26 27 28 29 30 31 32

/**
 * 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]
33 34 35 36
	special
		a	= Char
		a	= Int
		a	= Real
37 38 39 40 41 42 43 44 45 46 47

/**
 * 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
48 49 50 51
	special
		a	= Char
		a	= Int
		a	= Real
52 53 54 55 56 57 58 59 60 61 62

/**
 * 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
63 64 65 66
	special
		a	= Char
		a	= Int
		a	= Real
67 68 69 70 71
/**
 * The minimum element of a list using a custom ordering.
 * @param The custom {{`<`}} function
 */
minListBy :: (a a -> Bool) !.[a] -> a