StdOverloaded.dcl 3.83 KB
Newer Older
1 2
definition module StdOverloaded

Camil Staps's avatar
Camil Staps committed
3 4 5 6
/**
 * A number of common overloaded functions.
 */

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

Camil Staps's avatar
Camil Staps committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
/**
 * Add `arg1` to `arg2`.
 */
class  (+)  infixl 6	a	:: !a	!a	->	a				

/**
 * Subtract `arg2` from `arg1`.
 */
class  (-)  infixl 6	a	:: !a	!a	->	a 				

/**
 * Zero (unit element for addition).
 */
class  zero 			a	:: a							


/**
 * Multiply `arg1` with `arg2`.
 */
class  (*)  infixl 7	a	:: !a	!a	->	a				

/**
 * Divide `arg1` by `arg2`.
 */
class  (/)  infixl 7	a	:: !a	!a	->	a				

/**
 * One (unit element for multiplication).
 */
class  one 			a	:: a							


/**
 * True if `arg1` is equal to `arg2`.
 */
class  (==) infix  4	a	:: !a	!a	->	Bool			

/**
 * True if `arg1` is less than `arg2`.
 */
class  (<)  infix  4	a	:: !a	!a	->	Bool	 		

/**
 * True if `arg1` is an even number.
 */
class  isEven a :: !a -> Bool;							

/**
 * True if `arg1` is an odd  number.
 */
class  isOdd  a :: !a -> Bool;							


/**
 * Number of elements in `arg`.
 * Used for list-like structures. It should have O(n) complexity.
 */
class  length m	:: !(m a) -> Int						

/**
 * Slice a part from `arg1`.
 */
class  (%)  infixl 9	a	:: !a !(!Int,!Int)	-> a		


/**
 * Append the arguments.
 */
class  (+++) infixr 5	a 	:: !a	!a	-> a			


/**
 * `arg1` to the power of `arg2`.
 */
class  (^)  infixr 8	a	:: !a	!a 	->	a				

/**
 * Absolute value.
 */
class  abs  			a	:: !a		->	a				

/**
 * The sign of a thing.
 * @result `1` for a positive value; `-1` for a negative value; `0` for zero
 */
class  sign 			a	:: !a 		->	Int				

/**
 * Negate a thing.
 */
class  ~				a	:: !a 		->	a				

104

Camil Staps's avatar
Camil Staps committed
105 106 107 108
/**
 * `arg1` modulo `arg2`.
 */
class  (mod) infix 7 a :: !a !a -> a						
109

Camil Staps's avatar
Camil Staps committed
110 111 112 113
/**
 * The remainder after division of `arg1 / arg2`.
 */
class  (rem)	infix 7	a :: !a !a -> a 					
114

Camil Staps's avatar
Camil Staps committed
115 116 117 118
/**
 * Greatest common divisor.
 */
class  gcd a :: !a !a -> a								
119

Camil Staps's avatar
Camil Staps committed
120 121 122 123
/**
 * Least common multiple.
 */
class  lcm a :: !a !a -> a								
124 125


Camil Staps's avatar
Camil Staps committed
126 127 128 129
/**
 * Convert into {{`Int`}}.
 */
class  toInt			a	:: !a		->	Int				
130

Camil Staps's avatar
Camil Staps committed
131 132 133 134
/**
 * Convert into {{`Char`}}.
 */
class  toChar		a	:: !a		->	Char			
135

Camil Staps's avatar
Camil Staps committed
136 137 138 139
/**
 * Convert into {{`Bool`}}.
 */
class  toBool		a	:: !a		->	Bool			
140

Camil Staps's avatar
Camil Staps committed
141 142 143 144
/**
 * Convert into {{`Real`}}.
 */
class  toReal		a	:: !a		->	Real			
145

Camil Staps's avatar
Camil Staps committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
/**
 * Convert into {{`String`}}.
 */
class  toString		a	:: !a		->	{#Char}			


/**
 * Convert from {{`Int`}}.
 */
class  fromInt		a	:: !Int			-> a			

/**
 * Convert from {{`Char`}}.
 */
class  fromChar		a	:: !Char		-> a			

/**
 * Convert from {{`Bool`}}.
 */
class  fromBool		a	:: !Bool		-> a			

/**
 * Convert from {{`Real`}}.
 */
class  fromReal		a	:: !Real		-> a			

/**
 * Convert from {{`String`}}.
 */
class  fromString	a	:: !{#Char}		-> a			


/**
 * Logarithm base e.
 */
class  ln			a	:: !a 		->	a				

/**
 * Logarithm base 10.
 */
class  log10			a	:: !a 		->	a				

/**
 * e to to the power of `arg`.
 */
class  exp			a	:: !a 		->	a				

/**
 * Square root.
 */
class  sqrt			a	:: !a 		->	a				
197 198 199 200


//	Trigonometrical Functions:

Camil Staps's avatar
Camil Staps committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
/**
 * Sine.
 */
class  sin			a	:: !a		->	a				

/**
 * Cosine.
 */
class  cos			a	:: !a		->	a				

/**
 * Tangent.
 */
class  tan			a	:: !a		->	a				

/**
 * Arc Sine.
 */
class  asin			a	:: !a		->	a				

/**
 * Arc Cosine.
 */
class  acos			a	:: !a		->	a				

/**
 * Arc Tangent.
 */
class  atan			a	:: !a		->	a				

/**
 * Hyperbolic Sine.
 */
class  sinh			a	:: !a		->	a				

/**
 * Hyperbolic Cosine.
 */
class  cosh			a	:: !a		->	a				

/**
 * Hyperbolic Tangent.
 */
class  tanh			a	:: !a		->	a				

/**
 * Arc Hyperbolic Sine.
 */
class  asinh			a	:: !a		->	a				

/**
 * Arc Hyperbolic Cosine.
 */
class  acosh			a	:: !a		->	a				

/**
 * Arc Hyperbolic Tangent.
 */
class  atanh			a	:: !a		->	a