raku 中是否有类似 R-lang 列绑定或行绑定之类的东西。 R-lang cbind
例如
my @matrix = ^100 .rotor(10);
my @cbind = cbind( @matrix [*;1..2].rotor(2) , @matrix [*;3..4].rotor(2) )
my @rbind = rbind ( @matrix [1..2;*].rotor(10) , @matrix [3..4;*].rotor(10) ?
Run Code Online (Sandbox Code Playgroud) 如何操作包含结构化数据的两个集合。
例如
set(set(<a b c>), set(<d e f>)) ? set(set(<a b c>), set(<d e f>), set(<g h i>))#True
set(set(<a b c>), set(<d e f>)) eq set(set(<a b c>), set(<d e f>), set(<g h i>))#false
set(set(<a b c>), set(<d e f>)) ? set(set(<a b c>), set(<d e f>), set(<g h i>))#set(<a b c>), set(<d e f>))
Run Code Online (Sandbox Code Playgroud) 我正在大学学习化学,想尝试在Perl6或Perl中编写教科书示例,比如平衡化学式或其他过程!
然后我遇到的问题是关于perl6自定义运算符.当我使用该功能时,我觉得我一直在重复我的代码和我自己.它很难读写.我该如何简化这个?
#!/usr/bin/env perl6
use v6;
#basic SI(International System of Units) type
role MetricPrefix {
method baseOn ( Str $base , Numeric $input ) {
given $base {
when 'pico' { return $input * 10**-12 }
when 'namo' { return $input * 10**-9 }
when 'micro' { return $input * 10**-6}
when 'milli' { return $input * 10**-3 }
when 'centi' { return $input * 10**-2 }
when 'hecto' { return $input * 10**2 }
when 'kilo' { return $input …
Run Code Online (Sandbox Code Playgroud) 当我尝试在 raku 中修改矩阵时。我收到错误:
my @matrix = ^100 .rotor(10);
@matrix[1;*] = 1 xx 10
Cannot modify an immutable Int (10)
in block <unit> at <unknown file> line 1
@matrix[1;1] = 3
Cannot modify an immutable List ((10 11 12 13 14 15 1...)
in block <unit> at <unknown file> line 1
Run Code Online (Sandbox Code Playgroud)
为什么所有这些值都是不可变的值?