home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.6
/
ffcollection-1-6-1993-02.iso
/
ff_disks
/
061-090
/
ff_081.lha
/
Icon
/
Meander.icn
< prev
next >
Wrap
Text File
|
1987-06-30
|
770b
|
33 lines
#
# M E A N D E R I N G S T R I N G S
#
# This main procedure accepts specifications for meandering strings
# from standard input with the alphabet separated from the length by
# a colon.
procedure main()
local line, alpha, n
while line := read() do {
line ? if alpha := tab(upto(':')) then {
move(1)
if n := integer(tab(0)) then write(meander(alpha,n))
else write("erroneous input")
}
else write("erroneous input")
}
end
procedure meander(alpha,n)
local result, t, i, c, k
i := k := *alpha
t := n-1
result := repl(alpha[1],t)
while c := alpha[i] do {
if find(result[-t:0] || c,result)
then i -:= 1
else {result ||:= c; i := k}
}
return result
end