小编黃家億*_*黃家億的帖子

如何在 raku-lang 中对两个矩阵进行运算符连接?

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)

r raku

6
推荐指数
1
解决办法
142
查看次数

如何比较乐朗中的集合?

如何操作包含结构化数据的两个集合。

例如

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)

set raku

6
推荐指数
1
解决办法
88
查看次数

使用Perl 6自定义运算符

我正在大学学习化学,想尝试在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)

perl6 custom-operator

5
推荐指数
1
解决办法
225
查看次数

如何在 raku-lang 中修改矩阵

当我尝试在 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)

为什么所有这些值都是不可变的值?

raku

5
推荐指数
1
解决办法
98
查看次数

标签 统计

raku ×3

custom-operator ×1

perl6 ×1

r ×1

set ×1