1
我试图做一个scalar_multiplication
lambda函数,但我只能让我的第一个断言工作。我认为我需要考虑多个抽象层次,但我被卡住了。以下是我迄今为止标量乘法?
scalar_mult = lambda c, M: [x * c for x in M]
assert scalar_mult(1, [[1,2], [3,4]]) == [[1,2], [3,4]]
assert scalar_mult(2, [[1,2], [3,4]]) == [[2,4], [6,8]]