On Nov 3, 2006, at 12:57 PM, Jonathan Ellis wrote:

On Fri, 3 Nov 2006 11:05:42 -0700, "Levi Pearson" <[EMAIL PROTECTED]> said:
Lisp is designed for building large, complex programs, not one-line
throwaway scripts, so comparing its verbosity to perl is kind of
silly.

Hmm, I could substitute Java for Lisp there and be just as accurate. :)

Indeed you could. I imagine that if asked to program it in the style they use for their for-work perl programming, the size of a Java, Lisp, and Perl implementation of the core logic of this problem would be far closer than when attempting to write the shortest possible program in each of the languages.

But, just to be perverse, I did translate my Lisp program into a single line: (loop(if(let*((l(let((s(read-line)))(loop for i = 0 then(1+ j)as j = (position #\Space s :start i)collect(subseq s i j)while j)))(n(length l)))(catch 'f(reduce(lambda(x y)(let((d(abs(-(parse-integer x)(parse- integer y)))))(unless(and(> d 0)(< d n))(throw 'f nil))y))l)t)) (format t "match~%")(format t "not a match~%")))

It's essentially the same logic, and could possibly be compressed further, but I really don't feel like doing that.

                --Levi

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to