[plug] loop statement needed
Russell Steicke
r.steicke at bom.gov.au
Thu Mar 11 00:53:22 WST 2004
On Thu, Mar 11, 2004 at 12:06:39AM +0800, Ryan wrote:
> On Wed, 2004-03-10 at 23:51, Russell Steicke wrote:
> > A perl version requires a corresponding python version:
> >
> > python -c "for i in range(0,26): print chr(ord('A')+i)"
>
> And in true TIMTOWTDI fashion, another Perl version - without getting
> obfuscatious :)
>
> perl -e 'print join("\n",(A..Z))."\n"'
And out of nowhere comes a scheme version:
(letrec
((p (lambda (i)
(cond
((> i 25))
(else
(let ((c (integer->char (+ (char->integer #\A) i))))
(display (string c))
(newline))
(p (+ i 1)))))))
(p 0))
My scheme is very rusty (eg I can't quite figure out if the recursive
call to (p) really is in tail call position or not), and this type of
character I/O is not scheme's strong point by any means, but it does
work.
--
Russell Steicke
-- Fortune says:
"The question is rather: if we ever succeed in making a mind 'of nuts and
bolts', how will we know we have succeeded?
-- Fergal Toomey
"It will tell us."
-- Barry Kort
More information about the plug
mailing list