Compact syntax for 0-matrix?

Tamito Kajiyama kajiyama at grad.sccs.chukyo-u.ac.jp
Tue May 30 15:24:49 CEST 2000


Kirby Urner <urner at alumni.princeton.edu> writes:
> 
> Here's another function I like OK:
> 
>    def zeromatrix(n,m):
>         output = []
>         for i in range(n): output.append([0]*m)
>         return output

Or, more shortly,

    def zeromatrix(m, n):
        return map(lambda x: [0]*x, [n]*m)

It seems more time-consuming, though ;)

-- 
KAJIYAMA, Tamito <kajiyama at grad.sccs.chukyo-u.ac.jp>
--
KAJIYAMA, Tamito <kajiyama at grad.sccs.chukyo-u.ac.jp>



More information about the Python-list mailing list