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]]