DEF VAR stroka AS CHAR.
DEF VAR i AS INT.
DEF VAR j AS INT.
DEF VAR pretend AS
CHAR.
DEF VAR symbol AS CHAR.
DEF VAR povtor AS CHAR.
DEF VAR razd AS CHAR INIT "|".
stroka = "a*sqrt(1 +
(a + 1)*sqrt(1 + (a + 2)*sqrt(1
+ (a + 3)*sqrt(1 + (a + 4)*(a + 6)))))".
DO i = 0 TO 9:
symbol = SUBSTR(stroka, i + 1, 1).
IF INDEX(SUBSTR(stroka, i + 1), symbol) = 0 THEN
NEXT.
RUN bolee(SUBSTR(stroka, i + 1), symbol, OUTPUT povtor).
IF pretend = "" THEN pretend = povtor.
ELSE pretend = pretend + razd
+ povtor.
END.
povtor
= ENTRY(1, pretend, razd).
DO i = 1 TO NUM-ENTRIES(pretend, razd):
symbol = ENTRY(i, pretend, razd).
IF LENGTH(symbol)
> LENGTH(povtor) THEN povtor
= symbol.
END.
stroka
= REPLACE(stroka, povtor,
"|").
MESSAGE "povtor
= " povtor SKIP "äëèíà =" LENGTH(povtor)
SKIP stroka {vab.i}.
pretend = "".
stroka
= "(a + 0)*sqrt(1 + (a + 1)*sqrt(1
+ (a + 2)*sqrt(1 + (a + 3)*sqrt(1
+ (a + 4)*(a + 6)))))".
DO i = 0 TO 9:
symbol = SUBSTR(stroka, i + 1, 1).
IF INDEX(SUBSTR(stroka, i + 1), symbol) = 0 THEN
NEXT.
RUN bolee(SUBSTR(stroka, i + 1), symbol, OUTPUT povtor).
IF pretend = "" THEN pretend = povtor.
ELSE pretend = pretend + razd
+ povtor.
END.
povtor
= ENTRY(1, pretend, razd).
DO i = 1 TO NUM-ENTRIES(pretend, razd):
symbol = ENTRY(i, pretend, razd).
IF LENGTH(symbol)
> LENGTH(povtor) THEN povtor
= symbol.
END.
stroka = REPLACE(stroka, povtor, "|").
MESSAGE
"povtor = " povtor SKIP "äëèíà =" LENGTH(povtor)
SKIP stroka {vab.i}.
/***/ symbol = REPLACE(stroka, "|4", "|4|5"). MESSAGE "5-ûé ýëåìåíò = " REPLACE(symbol,
"|", povtor) {vab.i}.
pretend =
"".
stroka = "sqrt(1 + 2*sqrt(1 + 3*sqrt(1 + ...)))".
DO i = 0 TO 9:
symbol = SUBSTR(stroka, i + 1, 1).
IF INDEX(SUBSTR(stroka, i + 1), symbol) = 0 THEN
NEXT.
RUN bolee(SUBSTR(stroka, i + 1), symbol, OUTPUT povtor).
IF pretend = "" THEN pretend = povtor.
ELSE pretend = pretend + razd
+ povtor.
END.
povtor
= ENTRY(1, pretend, razd).
DO i = 1 TO NUM-ENTRIES(pretend, razd):
symbol = ENTRY(i, pretend, razd).
IF LENGTH(symbol)
> LENGTH(povtor) THEN povtor
= symbol.
END.
stroka
= REPLACE(stroka, povtor,
"|").
MESSAGE "povtor
= " povtor SKIP "äëèíà =" LENGTH(povtor)
SKIP stroka {vab.i}.
pretend = "".
stroka
= "sqrt(8-sqrt(8+sqrt(8-sqrt(8+...))))".
DO i = 0 TO 9:
symbol = SUBSTR(stroka, i + 1, 1).
IF INDEX(SUBSTR(stroka, i + 1), symbol) = 0 THEN
NEXT.
RUN bolee(SUBSTR(stroka, i + 1), symbol, OUTPUT povtor).
IF pretend = "" THEN pretend = povtor.
ELSE pretend = pretend + razd + povtor.
END.
povtor
= ENTRY(1, pretend, razd).
DO i = 1 TO NUM-ENTRIES(pretend, razd):
symbol = ENTRY(i, pretend, razd).
IF LENGTH(symbol)
> LENGTH(povtor) THEN povtor
= symbol.
END.
stroka
= REPLACE(stroka, povtor,
"|").
MESSAGE "povtor
= " povtor SKIP "äëèíà =" LENGTH(povtor)
SKIP stroka {vab.i}.
pretend = "".
stroka
= "sqrt(1+2 * sqrt(1+3
* sqrt(1+...)))".
DO i = 0 TO 9:
symbol = SUBSTR(stroka, i + 1, 1).
IF INDEX(SUBSTR(stroka, i + 1), symbol) = 0 THEN
NEXT.
RUN bolee(SUBSTR(stroka, i + 1), symbol, OUTPUT povtor).
IF pretend = "" THEN pretend = povtor.
ELSE pretend = pretend + razd + povtor.
END.
povtor
= ENTRY(1, pretend, razd).
DO i = 1 TO NUM-ENTRIES(pretend, razd):
symbol = ENTRY(i, pretend, razd).
IF LENGTH(symbol)
> LENGTH(povtor) THEN povtor
= symbol.
END.
stroka
= REPLACE(stroka, povtor,
"|").
MESSAGE "povtor
= " povtor SKIP "äëèíà =" LENGTH(povtor)
SKIP stroka {vab.i}.
pretend = "".
stroka
= "sqrt(1+2 * sqrt(1+3
* sqrt(1+4 * sqrt(1+...))))".
DO i = 0 TO 9:
symbol = SUBSTR(stroka, i + 1, 1).
IF INDEX(SUBSTR(stroka, i + 1), symbol) = 0 THEN
NEXT.
RUN bolee(SUBSTR(stroka, i + 1), symbol, OUTPUT povtor).
IF pretend = "" THEN pretend = povtor.
ELSE pretend = pretend + razd + povtor.
END.
povtor
= ENTRY(1, pretend, razd).
DO i = 1 TO NUM-ENTRIES(pretend, razd):
symbol = ENTRY(i, pretend, razd).
IF LENGTH(symbol)
> LENGTH(povtor) THEN povtor
= symbol.
END.
stroka
= REPLACE(stroka, povtor,
"|").
MESSAGE "povtor
= " povtor SKIP "äëèíà =" LENGTH(povtor)
SKIP stroka {vab.i}.
/****************
ïðîöåäóðû
***********************/
PROCEDURE bolee:
DEF INPUT PARAMETER str
AS CHAR.
DEF INPUT PARAMETER sym AS CHAR.
DEF OUTPUT PARAMETER rez AS CHAR.
DEF VAR i
AS INT.
rez = sym.
REPEAT:
i = INDEX(SUBSTR(str, LENGTH(rez) + 1), rez).
IF i = 0 THEN DO: rez = SUBSTR(rez,
1, LENGTH(rez) - 1).
RETURN. END.
rez
= rez + SUBSTR(str, LENGTH(rez) + 1, 1).
END.
END PROCEDURE. /* bolee */