StdCharList.dcl 1.59 KB
Newer Older
1 2
definition module StdCharList

Camil Staps's avatar
Camil Staps committed
3 4 5 6
/**
 * Basic functions for manipulating lists of characters.
 */

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
/**
 * Center-align a text with spaces, s.t. the right margin is 0 or 1 spaces
 * longer than the left margin.
 *
 * @param The minimum length of the result
 * @param The text to center
 * @result A list of max(|param 2|, param 1), with param 2 surrounded by spaces
 */
cjustify	:: !.Int ![.Char] -> .[Char]

/**
 * Left-align a text with spaces
 *
 * @param The minimum length of the result
 * @param The text to align
 * @result A list of max(|param 2|, param 1), with spaces appended to param 2
 */
ljustify	:: !.Int ![.Char] -> .[Char]

/**
 * Right-align a text with spaces
 *
 * @param The minimum length of the result
 * @param The text to align
 * @result A list of max(|param 2|, param 1), with spaces prepended to param 2
 */
rjustify	:: !.Int ![.Char] -> [Char]

/**
 * Concatenate a list of texts, interspersing it with newlines
 *
 * @param The texts
 * @result All texts concatenated, with newlines in between
 */
flatlines	:: ![[u:Char]] -> [u:Char]
47

Camil Staps's avatar
Camil Staps committed
48 49 50 51 52 53 54
/**
 * Split a text on newlines
 *
 * @param The text
 * @result A list of texts without newlines
 */
mklines 	:: ![Char] -> [[Char]]
55

Camil Staps's avatar
Camil Staps committed
56 57 58 59 60 61 62
/**
 * A list of a number of ' ' characters
 *
 * @param The number of characters
 * @result A list of param 1 spaces
 */
spaces		:: !.Int -> .[Char]