我有一个 java 称之为“bean”的类。我希望能够分阶段合并属性值,同时检查合并的任何内容是否与子方法 BUILD 签名相匹配:
class A {
has Int $.a;
has Str $.b;
submethod BUILD ( Int :$!a, Str :$!b ) { }
my Signature $sig = ( A.^methods.grep: { .name eq 'BUILD' } )[0].signature;
method fill-in ( *%args ) {
say 'filling-in';
my @args = %args.pairs;
@args.unshift: self;
say 'after unshift';
self.raku.say;
my Capture $arg-capture = @args.Capture;
say 'after Capture';
self.raku.say;
unless $arg-capture ~~ $sig {
warn '(warning)';
return;
}
my Str $name;
my %merged;
say 'after check'; …Run Code Online (Sandbox Code Playgroud) 我正在尝试在OS X 10.6上安装Rakudo Star,并且我已经达到了令人沮丧的地步,我的构建失败了,我不知道如何处理.这里有没有人知道这个过去的方法?(我正在尝试将其设置为编写一些本地perl6程序,所以我不确定规则是否在服务器故障或堆栈溢出时需要这个,请根据需要打我)
我已经下载了提供的发行版并运行了
make VERSION=2010.07
要在文件夹中成功创建实际分发
rakudo-star-2010.07
对于任何感兴趣的人,我需要获取gnu find的端口版本(安装到/ opt/local/bin/gfind),然后将我的常规find替换为gfind.OS X发现缺少-printf选项.
顺便说一句,按照我的说法,我
$ cd rakudo-star-2010.07 $ perl Configure.pl --gen-parrot
这突然间有一段时间,但后来保释如下
/Users/alanstorm/Downloads/rakudo-star-7652a0b/rakudo-star-2010.07/install/src/parrot/2.6.0/pmc/timer.dump /Users/alanstorm/Downloads/rakudo-star-7652a0b/rakudo-star-2010.07/install/src/parrot/2.6.0/pmc/undef.dump /Users/alanstorm/Downloads/rakudo-star-7652a0b/rakudo-star-2010.07/install/src/parrot/2.6.0/pmc/unmanagedstruct.dump /Users/alanstorm/Downloads/rakudo-star-7652a0b/rakudo-star-2010.07/install/src/parrot/2.6.0/vtable.dump Finished install_dev_files.pl Reading configuration information from install/bin/parrot_config ... ===SORRY!=== Parrot revision r48225 required (currently r0) To automatically build the version of Parrot that came with this distribution (), try re-running Configure.pl with the '--gen-parrot' option. Or, use the '--parrot-config' option to explicitly specify the location of parrot_config to be used to build …
#!perl6
use v6;
my $longest = 3;
my @list = <a b c d e f>;
for @list -> $element is rw {
$element = sprintf "%*.*s", $longest, $longest, $element;
$element.say;
}
Run Code Online (Sandbox Code Playgroud)
这有效.但在第二和第三,我得到一个错误信息.我怎么能让他们工作?
#!perl6
use v6;
my $longest = 3;
my @list = <a b c d e f>;
for @list <-> $element {
$element = sprintf "%*.*s", $longest, $longest, $element;
$element.say;
}
# ===SORRY!===
# Missing block at line 11, near ""
Run Code Online (Sandbox Code Playgroud)
.
#!perl6
use v6;
my $longest = …Run Code Online (Sandbox Code Playgroud) 在Perl 5中,我可以说
my $meth = 'halt_and_catch_fire';
my $result = $obj->$meth();
Run Code Online (Sandbox Code Playgroud)
这对于迭代方法名称列表来执行操作非常方便.我已经设法搞清楚在Perl 6中我不能只说
my $result = $obj.$meth();
Run Code Online (Sandbox Code Playgroud)
有一件事做的工作
my $result = $obj.^can($meth)[0]($obj);
Run Code Online (Sandbox Code Playgroud)
但这似乎完全可怕.我该怎么办呢?
我想将字符串拆分为单词并将每个单词打印在单独的行上,因此我尝试了以下操作:
"foo bar baz".words>>.say
Run Code Online (Sandbox Code Playgroud)
然而,结果并不顺利:
baz
foo
bar
Run Code Online (Sandbox Code Playgroud)
这有什么问题?
我想用惯用的Perl 6来做这件事.
我在一个嘈杂的输出文件中找到了一个很棒的连续数据块.
我想简单地打印出标题行,从Cluster Unique它后面的所有行开始,直到但不包括第一次出现空行.这是文件的样子:
</path/to/projects/projectname/ParameterSweep/1000.1.7.dir> was used as the working directory.
....
Cluster Unique Sequences Reads RPM
1 31 3539 3539
2 25 2797 2797
3 17 1679 1679
4 21 1636 1636
5 14 1568 1568
6 13 1548 1548
7 7 1439 1439
Input file: "../../filename.count.fa"
...
Run Code Online (Sandbox Code Playgroud)
这是我要解析的内容:
Cluster Unique Sequences Reads RPM
1 31 3539 3539
2 25 2797 2797
3 17 1679 1679
4 21 1636 1636
5 14 1568 1568
6 13 …Run Code Online (Sandbox Code Playgroud) 你会如何用 Raku/Perl6 的 Native Call 调用这个库?
https://developer.gnome.org/gtk3/stable/gtk3-Clipboards.html#gtk-clipboard-request-text
void
gtk_clipboard_request_text (GtkClipboard *clipboard,
GtkClipboardTextReceivedFunc callback,
gpointer user_data);
Run Code Online (Sandbox Code Playgroud)
非常感谢,-T
编辑:这个问题是如何调用函数。不要对失败的呼叫进行故障排除。此时没有编写代码。
raku ×8
perl6 ×4
rakudo-star ×3
compilation ×1
configure ×1
flip-flop ×1
for-loop ×1
parsing ×1
rakudo ×1
read-write ×1
termux ×1
text ×1