V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  smr1113  ›  全部回复第 1 页 / 共 1 页
回复总数  2
2019-08-08 17:34:25 +08:00
回复了 oldbird 创建的主题 Python 请教 Python 怎么进行列表的插值?
看错了~~
python:
from itertools import chain
list(chain(*zip(x, [(i+j)/2.0 for i,j in zip(x,x[1:])]))) + [x[-1]]
2019-08-08 17:23:44 +08:00
回复了 oldbird 创建的主题 Python 请教 Python 怎么进行列表的插值?
python:[x[0]] + [(i+j)/2.0 for i,j in zip(x,x[1:])]
函数式:
x.head :: (x zip x.tail map {case (x,y) => (x+y)/2.0})
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3820 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 04:21 · PVG 12:21 · LAX 21:21 · JFK 00:21
Developed with CodeLauncher
♥ Do have faith in what you're doing.