Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Data structures GNU-APL中带索引参数的行约简_Data Structures_Gnu_Fold_Apl - Fatal编程技术网

Data structures GNU-APL中带索引参数的行约简

Data structures GNU-APL中带索引参数的行约简,data-structures,gnu,fold,apl,Data Structures,Gnu,Fold,Apl,我使用以下数据结构: x1a ← 2 1 ⍴ 1 0 x1b ← ⍬ x2a ← 2 2 ⍴ 1 1 0 0 x2b ← 2 1 ⍴ 1 0 x3a ← 1 2 ⍴ 1 0 x3b ← 1 q ← (x3a x3b) (x2a x2b) (x1a x1b) 以及尝试与以下操作等效的行缩减: output ← x3b + x3a +.× x2b + x2a +.× x1a 我原以为结果与以下类似,但我无法获得正确的等级/操作: {⍵[2] + ⍺[1] +.× ⍵[1]}/q 感谢您的

我使用以下数据结构:

x1a ← 2 1 ⍴ 1 0
x1b ← ⍬

x2a ← 2 2 ⍴ 1 1 0 0
x2b ← 2 1 ⍴ 1 0

x3a ← 1 2 ⍴ 1 0
x3b ← 1

q ← (x3a x3b) (x2a x2b) (x1a x1b)
以及尝试与以下操作等效的行缩减:

output ← x3b + x3a +.× x2b + x2a +.× x1a
我原以为结果与以下类似,但我无法获得正确的等级/操作:

{⍵[2] + ⍺[1] +.× ⍵[1]}/q

感谢您的建议或帮助

有三个问题:

  • 您正在使用
    ⍵[1] 
    这将为您提供一个包含
    。使用
    改为“拾取”

  • 您有一个输入错误:
    ⍵[2] 
    应使用
    相反,即
    2⊃⍺

  • 使用reduce的函数期望其正确参数为两个元素的向量,其中只使用第一个元素。因此,它需要在下一次迭代中返回这样的结构

  • 还请注意,由于
    /
    需要将秩从1减少到0,结果都将被括起来,而且还将插入虚拟元素,因此我们需要选择唯一元素的第一个元素,即
    ⍬ 1.⊃

          x3b + x3a +.× x2b + x2a +.× x1a
    3
          ⍬ 1⊃{((2⊃⍺) + (1⊃⍺) +.× (1⊃⍵)) 'dummy'}/q
    3
    

    @cannadayr不客气。也许去公园看看?