Daftar Python perbedaan nilai beetwen dalam daftar
>>> t = [1, 3, 6]
>>> v = [t[i+1]-t[i] for i in range(len(t)-1)]
>>> v
[2, 3]
Tirbo06
>>> t = [1, 3, 6]
>>> v = [t[i+1]-t[i] for i in range(len(t)-1)]
>>> v
[2, 3]
v = np.diff(t)
v = np.diff(t + [t[-1]])
v = np.diff(np.append(t[0], t))
>>> t
[1, 3, 6]
>>> [j-i for i, j in zip(t[:-1], t[1:])] # or use itertools.izip in py2k
[2, 3]
v = np.diff([t[0]] + t) # for python 3.x