【发布时间】:2020-03-06 13:23:10
【问题描述】:
考虑表达式(1 2 3),¨(4 5 6)。我希望这会“将(1 2 3), 的操作映射到4、5 和6 上,答案如下:
(1 2 3),¨(4 5 6)
= (1 2 3),¨((4) (5) (6)) [Using (x) = x]
= (((1 2 3), 4) ((1 2 3), 5) ((1 2 3), 6)) [Using definition of map]
= ((1 2 3 4) (1 2 3 5) (1 2 3 6))
但是,这不是答案!在 Dyalog APL 中评估的答案是:
]display (1 2 3),¨(4 5 6)
┌→──────────────────┐
│ ┌→──┐ ┌→──┐ ┌→──┐ │
│ │1 4│ │2 5│ │3 6│ │
│ └~──┘ └~──┘ └~──┘ │
└∊──────────────────┘
怎么样?这个答案背后的原因是什么?我的等式推理哪里出错了?我应该注意的, (comma) 和¨(map) 的错误心理模型是否还有更多“陷阱”?
【问题讨论】:
标签: arrays map-function apl dyalog