|
| 1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 | +<HTML> |
| 3 | +<HEAD> |
| 4 | +<!-- EDIT --> |
| 5 | +<TITLE>Mozart Standard Library: String Support</TITLE> |
| 6 | +<STYLE> |
| 7 | +BODY { |
| 8 | + background-color: white; |
| 9 | + margin-left : 2cm; |
| 10 | + margin-right : 2cm; |
| 11 | + font-family : tahoma,arial,helvetica,sans-serif; |
| 12 | +} |
| 13 | +H1 { |
| 14 | + text-align : center; |
| 15 | + color : #9B0000; |
| 16 | +} |
| 17 | +H2 { color : #FF9933; } |
| 18 | +H4 { color : slateblue; } |
| 19 | +H3 { color : #881155; } |
| 20 | +H5 { color : darkslateblue; } |
| 21 | +CODE { color : #663366; } |
| 22 | +CODE,TT { |
| 23 | + font-family : "lucida console",courier,monospace; |
| 24 | +} |
| 25 | +CODE.DISPLAY { |
| 26 | + display : block; |
| 27 | + white-space : pre; |
| 28 | + margin-left : 2cm; |
| 29 | + margin-top : 1em; |
| 30 | + margin-bottom : 1em; |
| 31 | +} |
| 32 | +P.AUTHOR { |
| 33 | + text-align : center; |
| 34 | + font-weight : bold; |
| 35 | +} |
| 36 | +SPAN.MODULE { |
| 37 | + color : steelblue; |
| 38 | +} |
| 39 | +A { color : steelblue; } |
| 40 | +SPAN.COMMENT { color: #B22222; } |
| 41 | +SPAN.KEYWORD { color: #A020F0; } |
| 42 | +SPAN.STRING { color: #BC8F8F; } |
| 43 | +SPAN.FUNCTIONNAME { color: #0000FF; } |
| 44 | +SPAN.TYPE { color: #228B22; } |
| 45 | +SPAN.VARIABLENAME { color: #B8860B; } |
| 46 | +SPAN.REFERENCE { color: #5F9EA0; } |
| 47 | +SPAN.BUILTIN { color: #DA70D6; } |
| 48 | +</STYLE> |
| 49 | +</HEAD> |
| 50 | +<BODY> |
| 51 | +<!-- EDIT --> |
| 52 | +<H1>String Support</H1> |
| 53 | +<P CLASS="AUTHOR">Denys Duchier</P> |
| 54 | +<DL> |
| 55 | + <DT><B>module</B> |
| 56 | + <DD><SPAN CLASS="MODULE">x-oz://system/String.ozf</SPAN> |
| 57 | +</DL> |
| 58 | +<HR> |
| 59 | + |
| 60 | +<P>This module provides additional convenience operation on strings. |
| 61 | +It should not be confused, with the base <CODE>String</CODE> which is |
| 62 | +always present and does not need to be imported. |
| 63 | + |
| 64 | +<H2>Exports</H2> |
| 65 | + |
| 66 | +<DL> |
| 67 | +<DT><CODE>{String.make +VS ?S}</CODE> |
| 68 | +<DD>turns a virtual string into a plain old regular string |
| 69 | +<DT><CODE>{String.length +S ?N}</CODE> |
| 70 | +<DD>returns the length <CODE>N</CODE> of string <CODE>S</CODE> |
| 71 | +<DT><CODE>{String.toInt +S ?I}</CODE> |
| 72 | +<DD>takes a string <CODE>S</CODE> and returns the integer <CODE>I</CODE> of |
| 73 | +which it is the textual representation |
| 74 | +<DT><CODE>{String.toFloat +S ?F}</CODE> |
| 75 | +<DD>takes a string <CODE>S</CODE> and returns the float <CODE>F</CODE> of |
| 76 | +which it is the textual representation |
| 77 | +<DT><CODE>{String.toInt +S ?A}</CODE> |
| 78 | +<DD>takes a string <CODE>S</CODE> and returns the corresponding |
| 79 | +atom <CODE>A</CODE> |
| 80 | +<DT><CODE>{String.capitalize +S1 ?S2}</CODE> |
| 81 | +<DD>takes a string <CODE>S1</CODE> and returns a string <CODE>S2</CODE> |
| 82 | +which is identical except for the first letter which has been capitalized |
| 83 | +<DT><CODE>{String.split +S +Sep ?L}</CODE> |
| 84 | +<DD>splits string <CODE>S</CODE> at all occurrences of string <CODE>Sep</CODE> |
| 85 | +and returns the resulting list <CODE>L</CODE>. <CODE>Sep</CODE> may also be |
| 86 | +<CODE>unit</CODE> in which case splits occur at all non-empty sequences of |
| 87 | +whitespace characters. It can also be <CODE>unit</CODE>, in which case |
| 88 | +splits occur between every two character |
| 89 | +<DT><CODE>{String.splitAtMost +S +Sep +N ?L}</CODE> |
| 90 | +<DD>same as above, but at most <CODE>N</CODE> splits are performed: the |
| 91 | +remainder of the string is returned as the last element of list <CODE>L</CODE> |
| 92 | +<DT><CODE>{String.lstrip +S1 +Chars ?S2}</CODE> |
| 93 | +<DD>takes a string a string <CODE>S1</CODE> and returns a string |
| 94 | +<CODE>S2</CODE> where all characters at the left of <CODE>S1</CODE> |
| 95 | +which are in <CODE>Chars</CODE> have been removed. <CODE>Chars</CODE> |
| 96 | +can also be <CODE>unit</CODE>, in which case it stands for all whitespace |
| 97 | +characters |
| 98 | +<DT><CODE>{String.rstrip +S1 +Chars ?S2}</CODE> |
| 99 | +<DD>same thing but at the right-end of <CODE>S1</CODE> |
| 100 | +<DT><CODE>{String.strip +S1 +Chars ?S2}</CODE> |
| 101 | +<DD>same thing at both ends |
| 102 | +<DT><CODE>{String.replace +S1 +Old +New ?S2}</CODE> |
| 103 | +<DD>replace every occurrence of string <CODE>Old</CODE> in <CODE>S1</CODE> |
| 104 | +by <CODE>New</CODE> |
| 105 | +<DT><CODE>{String.replaceAtMost +S1 +Old +New +N ?S2}</CODE> |
| 106 | +<DD>same as above, but replace at most <CODE>N</CODE> occurrences of |
| 107 | +<CODE>Old</CODE> |
| 108 | +</DL> |
| 109 | + |
| 110 | +<HR> |
| 111 | +</BODY> |
| 112 | +</HTML> |
0 commit comments