Hi,
I saw a perl script in USENET news that coded text to CW -alphabets,
the author of script challenged others to do the same with a shorter
program. I thought to do it in REBOL. Here it is, much shorter than
the original perl -script, that was actually very badly written, but
unfortunately a bit longer than the shortest (and very unreadable)
perl script. This script is a bit broken (because I tried to take
every byte off that I could). And almost unreadable. It is certainly
not a good example how one should program in REBOL. I post it
here just because there might be some interested in it. Here it comes
(about 210 bytes :)
REBOL[]foreach c system/script/args[s: copy{ }x: index?
find{etianmsurwdkgohvf�l�pjbxcyzq�*54*3***2*******16*******7***8*90}c until[s:
head insert s either odd? x["."]["-"](x: to-integer x - 1 / 2) = 0]prin s]
And a little more readable version:
REBOL[]
foreach char system/script/args [
str: copy " "
pos: index? find
"etianmsurwdkgohvf�l�pjbxcyzq�*54*3***2*******16*******7***8*90" char
until [
str: head insert str either odd? pos ["."]["-"]
(pos: to-integer pos - 1 / 2) = 0
]
prin str
]
It is supposed to be used from the commandline, but it is easy to
alter do otherwise. I'll repeat this, if you want to use this code
snippet in your program do yourself a favor and fix it, currently it
is hmm... feature rich :) It does not like spaces in input and
also unknown characters produce a crash.
Have fun,
Jussi
--
Jussi Hagman CS in �bo Akademi University
Studentbyn 4 D 33 [EMAIL PROTECTED]
20540 �bo [EMAIL PROTECTED]
Finland