我想map()在javascript数组上使用该函数,但我希望它以相反的顺序运行.
原因是,我在Meteor项目中渲染堆叠的React组件,并希望顶层元素首先渲染,而其余元素在下面加载.
var myArray = ['a', 'b', 'c', 'd', 'e'];
myArray.map(function (el, index, coll) {
console.log(el + " ")
});
Run Code Online (Sandbox Code Playgroud)
打印出来,a b c d e但我希望有一个打印的mapReverse()e d c b a
有什么建议?
我正试图在Meteor 1.3测试版中设置cloudinary,我现在正在寻找NPM软件包.我遇到了一个更大的问题,其中一个软件包库中有一个声明 crypto = require('crypto');很好.我刚刚通过npm安装了加密包.但客户仍然给我错误Uncaught Error: Cannot find module 'crypto'.… 有什么建议?
注意,两个模块都在同一个node_modules目录中:
node_modules
crypto
material-ui
react
react-cloudinary
react-dom
react-mounter
react-tap-event-plugin
Run Code Online (Sandbox Code Playgroud)
这是一个Meteor 1.3问题,因为我正在导入npm库
我正在尝试使用100x6 numpy数组写入数据文件
# print array to file
data = open("store.dat", "w")
for j in xrange(len(array)):
data.write(str(array[i]) + "\n")
Run Code Online (Sandbox Code Playgroud)
但是当文件写入时,它会自动拆分68个字符后的行,即6列数组的5列.例如,我想看
[ 35.47842918 21.82382715 3.18277209 0.38992263 1.17862342 0.46170848]
Run Code Online (Sandbox Code Playgroud)
作为其中一条线,但我得到了
[ 35.47842918 21.82382715 3.18277209 0.38992263 1.17862342
0.46170848]
Run Code Online (Sandbox Code Playgroud)
我把它缩小到一个问题,str(array[i])并决定让自己成为一个新的界限.
其次,有没有更好的方法来解决这个问题?我对python很新,对它的正确编码知之甚少.最后,我正在编写一个星星模拟,以后会被一个模块读取,该模块将在VPython中渲染坐标.我想,为了避免实时渲染的问题,我可以在模拟完成后传递一个文件.这效率低吗?我应该通过一个对象吗?
谢谢