StdOrdList.dcl 1.43 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

Camil Staps's avatar
Camil Staps committed
14 15
//* Sort a list (mergesort).
sort    ::               !u:[a] -> u:[a] | Ord a
16 17 18 19
	special
		a	= Char
		a	= Int
		a	= Real
Camil Staps's avatar
Camil Staps committed
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]
29 30 31 32
	special
		a	= Char
		a	= Int
		a	= Real
Camil Staps's avatar
Camil Staps committed
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
42 43 44 45
	special
		a	= Char
		a	= Int
		a	= Real
Camil Staps's avatar
Camil Staps committed
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
55 56 57 58
	special
		a	= Char
		a	= Int
		a	= Real
Camil Staps's avatar
Camil Staps committed
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