On 3/11/06, Pawel Kraszewski <[EMAIL PROTECTED]> wrote: > Dnia piątek, 10 marca 2006 19:31, Edgar Antonio Rodriguez Velazco napisał: > > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 > > Oh God! This smells lispish! Haven't seen a jevel like this before, but I LOVE > it!
Haha, hey, I've been learning Lisp and at least it'd have brackets in places to make precedence easier to grok. This reminds me, some friends and I were discussing various languages and writing code that generates a string of the first five squares, space delimited. i.e. x = [] for i in range(1, 6): w = str(i) x.append(w) print " ".join(x) Which rapidly turned into an obfuscation contest. I was amazed at how obfuscated you could be in Python, thus proving the adage that you can write Perl in any language. A relatively intelligble one liner is print " ".join([str(i * i) for item in range(1,6)]) A very obfuscated (using lambda and abusing a list comprehension) one is [sys.stdout.write(str((lambda y: y*y)(x))+" ") for x in range(1,6)] (But it also returns [None, None, None, None, None, None] ) And my favourite, because it looks like Lisp/Haskell - print " ".join(map(str, map(lambda x: x*x, range(1,6)))) (My Common Lisp attempt was - (string-trim "()" (write-to-string (loop for i from 1 to 5 collecting (* i i)) :array T)) but I'm such a Lisp newbie it's not funny.) /end OT _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor