Another attempt to produce a succint yet readable solution...
(for some reason I found myself writing as if it was Forth... ;-))
<pre>
(set
'atext [text]os zyexdzaxr aex ... as previous post ...
apcniai. (hhh.tdaznt.qin/zyak/dcos) [/text]
'freq-lang "TEOAINRHSLMCYUDWGQFBPVKZXJ")
(define (in-range? x low high) (and (>= x low) (<= x high)))
(define (letter? c) (or
(in-range? (char c) (char "a") (char "z"))
(in-range? (char c) (char "A") (char "Z"))))
(set 'letters-used (unique (sort (filter letter? (explode atext)))))
(set 'letter-freq-table (map list letters-used (count letters-used (explode atext))))
(sort letter-freq-table (fn (x y) (> (last x) (last y))))
(set 'dict (map (fn (e f) (list (first e) (last e) f)) letter-freq-table (explode freq-lang)))
(map (fn (chr)
(set 'letter (lookup (lower-case chr) dict))
(set 'upper-case? (in-range? (char chr) (char "A") (char "Z")))
(if letter
(if upper-case? (print letter) (print (lower-case letter)))
(if upper-case? (print chr) (print (lower-case chr)))
))
(explode atext))
(exit)</pre>
;->
"by inherited the Perl philosophy of having more than one way
to do the same thing. I inherited that philosophy from Larry Wall,
who is my hero actually. I want to make Ruby users free. I want to
give them the freedom to choose. People are different. People choose
different criteria. But if there is a better way among many
alternatives, I want to encourage that way by making it comfortable.
So that's what I've tried to do.
I want to solve problems I meet in the daily life by using computers,
so I need to write programs. By using Ruby, I want to concentrate the
things I do, not the magical rules of the language, like starting with
public void something something something to say, "print hello world."
I just want to say, "print this!" I don't want all the surrounding
magic keywords. I just want to concentrate on the task. That's the basic
idea. So I have tried to make Ruby code concise and succinct."
Yukihiro Matsumoto. (
www.artima.com/intv/ruby)
We like Ruby too (though not quite as much as newLISP :-))
Here's a quote from a language whose designer's
name also ends with *tz (Lutz not Matz):
"newLISP relies on a minimum of theoretical concepts. It
does not implement many paradigms or principles
discovered or invented in Computers Science and used in
other computer languages. The LISP list is the basic
paradigm for data and program structure and is enough to
capture, represent and process the highest degree of
complexity.
newLISP is very small and has built-in most of the
technologies needed in today's networked and
distributed applications. Tomorrow's software systems
are not constituted by big monolithic systems but small
agile agents running and cooperating on distributed
architectures. newLISP is small enough to run on
embedded systems or distributed server farms built from
thousands of small simple computer nodes.
newLISP recognizes the changing nature of progressing
technology and constantly tries to adapt to it. Over
the years the functionality found in newLISP has
undergone many changes adapting to what is necessary at
the time.
The newLISP Philosophy can be expressed with the few
words simple, small, agile, cooperative, adapting."