Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
/* REXX ***************************************************************
|
||||
* 25.05.2014 Walter Pachl
|
||||
* REXX strings start with position 1
|
||||
**********************************************************************/
|
||||
Call enc_dec 'broood'
|
||||
Call enc_dec 'bananaaa'
|
||||
Call enc_dec 'hiphophiphop'
|
||||
Exit
|
||||
enc_dec: Procedure
|
||||
Parse Arg in
|
||||
st='abcdefghijklmnopqrstuvwxyz'
|
||||
sta=st /* remember this for decoding */
|
||||
enc=''
|
||||
Do i=1 To length(in)
|
||||
c=substr(in,i,1)
|
||||
p=pos(c,st)
|
||||
enc=enc (p-1)
|
||||
st=c||left(st,p-1)substr(st,p+1)
|
||||
End
|
||||
Say ' in='in
|
||||
Say 'sta='sta 'original symbol table'
|
||||
Say 'enc='enc
|
||||
Say ' st='st 'symbol table after encoding'
|
||||
out=''
|
||||
Do i=1 To words(enc)
|
||||
k=word(enc,i)+1
|
||||
out=out||substr(sta,k,1)
|
||||
sta=substr(sta,k,1)left(sta,k-1)substr(sta,k+1)
|
||||
End
|
||||
Say 'out='out
|
||||
Say ' '
|
||||
If out==in Then Nop
|
||||
Else
|
||||
Say 'all wrong!!'
|
||||
Return
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/*REXX program demonstrates the move─to─front algorithm encode/decode symbol table. */
|
||||
parse arg xxx; if xxx='' then xxx= 'broood bananaaa hiphophiphop' /*use the default?*/
|
||||
one= 1 /*(offset) for this task's requirement.*/
|
||||
do j=1 for words(xxx); x= word(xxx, j) /*process a single word at a time. */
|
||||
@= 'abcdefghijklmnopqrstuvwxyz'; @@= @ /*symbol table: the lowercase alphabet */
|
||||
$= /*set the decode string to a null. */
|
||||
do k=1 for length(x); z= substr(x, k, 1) /*encrypt a symbol in the word. */
|
||||
_= pos(z, @); if _==0 then iterate /*the symbol position in symbol table. */
|
||||
$= $ (_ - one); @= z || delstr(@, _, 1) /*(re─)adjust the symbol table string. */
|
||||
end /*k*/ /* [↑] the move─to─front encoding. */
|
||||
!= /*set the encode string to a null. */
|
||||
do m=1 for words($); n= word($, m) + one /*decode the sequence table string. */
|
||||
y= substr(@@, n, 1); != ! || y /*the decode symbol for the N word.*/
|
||||
@@= y || delstr(@@, n, 1) /*rebuild the symbol table string. */
|
||||
end /*m*/ /* [↑] the move─to─front decoding. */
|
||||
say ' word: ' left(x, 20) "encoding:" left($, 35) word('wrong OK', 1 + (!==x) )
|
||||
end /*j*/ /*stick a fork in it, we're all done. */
|
||||
Loading…
Add table
Add a link
Reference in a new issue