我正在尝试在Raspberry Pi 3上安装Rakudo Star 2018.04.
我做:
sudo perl Configure.pl --gen-moar --gen-nqp --prefix ~/rakudo
Run Code Online (Sandbox Code Playgroud)
它成功完成.
然后我尝试:
sudo make-install
Run Code Online (Sandbox Code Playgroud)
但它失败了:
The following step can take a long time, please be patient.
/home/pi/rakudo/bin/moar --libpath="blib" --libpath="/home/pi/rakudo/share/nqp/lib" --libpath="/home/pi/rakudo/share/nqp/lib" perl6.moarvm --nqp-lib=blib --setting=NULL --ll-exception --optimize=3 --target=mbc --stagestats --output=CORE.setting.moarvm gen/moar/CORE.setting
Stage start : 0.000
Stage parse : 459.019
Stage syntaxcheck: 0.000
Stage ast : 0.000
Stage optimize : Killed
Makefile:504: recipe for target 'CORE.setting.moarvm' failed
make[1]: *** [CORE.setting.moarvm] Error 137
make[1]: Leaving directory '/home/pi/rakudo-star-2018.04/rakudo'
Makefile:43: recipe for target …Run Code Online (Sandbox Code Playgroud) 我试图用Perl6做一些OOP并且在角色方面遇到一些麻烦.我试图以类似于Java接口的方式使用它们,在那里我只有方法签名,必须由任何扮演角色的类实现.我使用带有类型参数的stubbed方法并返回.
我注意到类型签名没有被强制执行,只有方法的名称.
示例脚本:
#!/usr/bin/env perl6
use v6;
role MyRole {
method intAdder( Int $a, Int $b --> Int ) { ... }
}
# this does the role and the method signature matches
class MyClass1 does MyRole {
method intAdder( Int $a, Int $b --> Int ) { return $a+$b }
}
# this does the role and the method signature does NOT match
# why is this allowed?
class MyClass2 does MyRole {
method intAdder( Str $a --> Str …Run Code Online (Sandbox Code Playgroud) 我有一些由本机sub返回的大型CArrays,我需要执行基本的元素数学运算.CArrays通常大约为10 ^ 6个元素.我发现在他们身上调用.list会将它们视为正常的Perl6类型非常昂贵.有没有办法在保持CArrays的同时对它们执行高性能的元素操作?
简短的测试脚本来计算我尝试过的一些方法:
#!/usr/bin/env perl6
use v6.c;
use NativeCall;
use Terminal::Spinners;
my $list;
my $carray;
my $spinner = Spinner.new;
########## create data stuctures ##########
print "Creating 10e6 element List and CArray ";
my $create = Promise.start: {
$list = 42e0 xx 10e6;
$carray = CArray[num32].new($list);
}
$spinner.await: $create;
########## time List subtractions ##########
my $time = now;
print "Substracting two 10e6 element Lists w/ hyper ";
$spinner.await( Promise.start: {$list >>-<< $list} );
say "List hyper subtraction took: {now - …Run Code Online (Sandbox Code Playgroud) 从单独的线程(例如,开始块、Proc::Async 或包含这些的子程序)传播错误的最佳方法是什么。简单地将在 try/CATCH 块中分出新线程的代码包装起来是行不通的,并且使用 await 仅根据子例程的返回值起作用(即,子返回 self 不适用于 await 方法)。
我将使用10 ^ 6 +元素对多个向量进行元素乘法.这在标题中被标记为我的代码中最慢的部分之一,所以我该如何改进它?
/// element-wise multiplication for vecs
pub fn vec_mul<T>(v1: &Vec<T>, v2: &Vec<T>) -> Vec<T>
where
T: std::ops::Mul<Output = T> + Copy,
{
if v1.len() != v2.len() {
panic!("Cannot multiply vectors of different lengths!")
}
let mut out: Vec<T> = Vec::with_capacity(v1.len());
for i in 0..(v1.len()) {
out.push(v1[i] * v2[i]);
}
out
}
Run Code Online (Sandbox Code Playgroud) 我在youtube上观看了关于PyQt4信号的简短教程,并且无法运行一个小样本程序.如何将从线程发出的信号连接到主窗口?
import cpuUsageGui
import sys
import sysInfo
from PyQt5 import QtCore
"""Main window setup"""
app = cpuUsageGui.QtWidgets.QApplication(sys.argv)
Form = cpuUsageGui.QtWidgets.QWidget()
ui = cpuUsageGui.Ui_Form()
ui.setupUi(Form)
def updateProgBar(val):
ui.progressBar.setValue(val)
class ThreadClass(QtCore.QThread):
def run(self):
while True:
val = sysInfo.getCpu()
self.emit(QtCore.pyqtSignal('CPUVALUE'), val)
threadclass = ThreadClass()
# This section does not work
connect(threadclass, QtCore.pyqtSignal('CPUVALUE'), updateProgBar)
# This section does not work
if __name__ == "__main__":
threadclass.start()
Form.show()
sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud) 我有一个使用NativeCall的模块,可以在Linux和macOS上运行,但不能在Windows上运行.当我尝试在Windows上使用该模块时,我遇到了很多错误,例如:
# Cannot locate symbol 'TinyTIFFReader_open' in native library 'tinytiff.dll'
Run Code Online (Sandbox Code Playgroud)
我使用cmake来解决所有三个操作系统上的C++依赖问题.在Linux和macOS上我可以cmake ..; make; sudo make install,在Windows上cmake -G "Visual Studio 15 2017 Win64" ..然后在Visual Studio中打开创建的".sln"进行编译.构建成功,所有三个操作系统都没有错误.
有没有人知道我需要做什么/更改以使我的模块在Windows上工作?
我想将一个大向量分块成一个向量向量。我知道chunks(),但不确定从迭代器到 2D 的最佳方式Vec。我发现以下方法可行,但是有没有更好的方法来编写它?
let v: Vec<i32> = vec![1, 1, 1, 2, 2, 2, 3, 3, 3];
let v_chunked: Vec<Vec<i32>> = v.chunks(3).map(|x| x.to_vec()).collect();
println!("{:?}", v_chunked); // [[1, 1, 1], [2, 2, 2], [3, 3, 3]]
Run Code Online (Sandbox Code Playgroud)
与此类似的操作是分析后我程序中最慢的部分之一,我想知道如何改进它。
perl6 ×4
nativecall ×2
raku ×2
rakudo ×2
rust ×2
cmake ×1
iterator ×1
optimization ×1
performance ×1
pyqt ×1
pyqt5 ×1
python ×1
python-3.x ×1
qt ×1
rakudo-star ×1
raspberry-pi ×1
slice ×1
vector ×1