Commit b7de9f40 authored by Pietro Abate's avatar Pietro Abate

[r2007-01-01 14:58:02 by afrisch] int_of_char

Original author: afrisch
Date: 2007-01-01 14:58:02+00:00
parent b3deb7c8
Since 0.4.1
- Added int_of_char
0.4.1
- Tools:
......
......@@ -168,6 +168,13 @@ register_fun "char_of_int"
with Failure _ -> raise (Lazy.force exn_int_of))
| _ -> assert false);;
register_fun "int_of_char"
(Types.char Chars.any) int
(function
| Value.Char x ->
Value.Integer (Intervals.V.from_int (Chars.V.to_int x))
| _ -> assert false);;
register_fun "string_of"
any string_latin1
......
......@@ -667,13 +667,14 @@ to be of type <code>[ '-'? '0'--'9'+ ] | ['-'? 'O'('b'|'B') '0'--'1'+ ] |
</p>
</section>
<section title="Creating strings from integers">
<section title="Creating characters from integers and characters from integers">
<p>
Besides the built-in function <code>string_of: Any -> Latin1</code>, it is
also possible to create characters, hence strings, from their codepoints:
either by enclosing their code within a backslash (<code>\x</code> for
hexadecimal code) and a semicolon, or by applying the built-in function
<code>char_of_int : Int -> Char</code>.
<code>char_of_int : Int -> Char</code>. The reverse function
<code>int_of_char : Char -> Int</code> is available as well.
</p>
</section>
......
......@@ -50,7 +50,7 @@ _" character, starting by a lowercase letter or underscore.</li>
<code>'\r'</code> return, <code>'\\'</code> backslash).</li>
<li>Types: intervals <code>'a'--'z', '0'--'9'</code>,
singletons <code>'a','b','c',...</code> </li>
<li>Operators: <code>char_of_int</code> : Int -> Char</li>
<li>Operators: <code>char_of_int</code> : Int -> Char, <code>int_of_char</code> : Char -> Int</li>
</ul>
</li>
<li>Symbolic atoms:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment