Calling J from Python

George Sakkis george.sakkis at gmail.com
Fri Feb 9 23:31:28 EST 2007


On Feb 9, 9:20 pm, bearophileH... at lycos.com wrote:
> ant:
>
> > and in debugging it far outweighs the time you'd spend on all
> > of that typing in a clean but more verbose language such as Python.
>
> Typing time counts a bit too. A language like Java is even more
> verbose than Python, and that probably slows down the actual
> programming, compared to less verbose languages. I think there is some
> verbosity sweet spot between J and Java, and for me that's called
> Python ;-)
>
> Martin Lüthi:
>
> > more elegant solutions sought!
>
> This is a bit simpler, but probably there are simpler solutions using
> modular arithmetic:
>
> l = [1]
> for _ in range(15):
>     print ''.join(" *"[x] for x in l)
>     l = [1] + [l[i+1]^l[i] for i in range(len(l)-1)] + [1]
>
> Bye,
> bearophile

Here's another one, adapted from the example (in Java) in Wikipedia's
entry (http://en.wikipedia.org/wiki/Sierpinski_triangle):

N=15
for x in xrange(N,0,-1):
    print ''.join('* '[x&y!=0] for y in xrange(N+1-x))


George




More information about the Python-list mailing list