Calling J from Python

Martin Lüthi answer at tnoo.net
Fri Feb 9 18:24:32 EST 2007


Alexander

Alexander Schmolck <a.schmolck at gmail.com> writes:
> I can think of two nice ways in J, 13 and 16 characters long respectively and
> each expressing something essential and non-trival about the problem in a way
> that would be more cumbersome in python.
>
> Here's the first one:
>
> (,,.~)^:4,'*'                  NB. due to Cliff Reiter, slightly adapted

Well, not as interesting as your solution, but definitively less mind-boggling
and much more flexible/extendible

====================================================
l  = [True]
pr = {True: '*', False: ' '}

for k in range(15):
    print ''.join([pr[x] for x in l])
    l = [True] + [l[i+1]^l[i] for i in range(len(l)-1)] + [True]
====================================================

more elegant solutions sought!

tnoo



More information about the Python-list mailing list