LZW compression: Difference between revisions

m
→‎version 2: added a blank line to the output.
m (→‎version 2: changed whitespace and comments, simplified some code.)
m (→‎version 2: added a blank line to the output.)
Line 4,898:
This REXX version can execute on   '''ASCII'''   or   '''EBCDIC'''   systems.
<lang rexx>/*REXX program compresses text using the LZW (Lempel─Ziv─Welch), and reconstitutes it.*/
$$$= '"There is nothing permanent except change." ─── Heraclitus [540 ── 475 BCE]'
parse arg xtext; if xtext='' then xtext= , $$$ /*get an optional argument from the CL.*/
'"There is nothing permanent except change." ─── Heraclitus [540 ── 475 BCE]'
say 'original text=' x text /* [↑] Not specified? Then use default*/
cypher= LZWc(xtext) /*compress text using the LZW algorithm*/
say 'reconstituted=' LZWd(cypher) /*display the reconstituted string. */
say; say ' LZW integers=' cypher /* " " LZW integers used. */
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 4,925:
original text= "There is nothing permanent except change." ─── Heraclitus [540 ── 475 BCE]
reconstituted= "There is nothing permanent except change." ─── Heraclitus [540 ── 475 BCE]
 
LZW integers= 34 84 104 101 114 101 32 105 115 32 110 111 116 104 105 110 103 32 112 259 109 97 110 101 110 116 32 101 120 99 101 112 281 99 104 277 103 101 46 34 32 296 196 298 296 32 72 259 97 99 108 105 116 117 264 32 91 53 52 48 32 299 52 55 53 32 66 67 69 93
</pre>