OracleGenImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Jean Gastinel August 12, 1987 7:28:18 pm PDT
~
BEGIN
Bin:
PUBLIC
PROC [k:
CARD]
RETURNS [s: Rope.
ROPE] ~ {
Transform the integer into a Rope which is the binary value of the integer]
s ← Convert.RopeFromCard[from: k, base: 2, showRadix: FALSE];
};
Hex:
PUBLIC
PROC [k:
CARD]
RETURNS [s: Rope.
ROPE] ~ {
Convert an integer into a Rope which correspond to its value
s ← Convert.RopeFromCard[from: k, base: 16, showRadix: FALSE];
};
LExtend:
PUBLIC
PROC [r: Rope
.ROPE, i:
INT]
RETURNS [s: Rope
.ROPE] ~ {
Left extend the initial Rope by 0 until having the length "i"
IF i < Rope.Length[r] THEN ERROR ;
s ← r;
DO
IF i= Rope.Length[s] THEN EXIT
ELSE s ← Rope.Concat["0",s];
ENDLOOP;
};
BinExt:
PUBLIC
PROC [k:
INT, i:
INT]
RETURNS [r: Rope
.ROPE] ~ {
Convert an Integer to a Rope with left 0 padding for a length of i
r ← LExtend[Bin[k],i];
};
Expand:
PUBLIC
PROC [r: Rope
.ROPE, i:
INT]
RETURNS [s: Rope
.ROPE] ~ {
Expand the initial Rope in inserting "i" space between each digit
n: INT;
b: Rope.ROPE;
b ← "";
FOR i IN [0..i) DO b ← Rope.Concat[" ",b] ENDLOOP;
n ← Rope.Length[r];
s ← "";
FOR i IN [0..n) DO s ← Rope.Cat[s,b,Rope.Substr[r,i,1]] ENDLOOP;
};