arrays - J 动词的数组参数 "compatible shape"是什么构成的?

标签 arrays arguments j

我正在学习(并且让我大吃一惊)J,并阅读学习J。我注意到我学习的许多(所有?)动词的论点都非常灵活。我可以执行传统的 4 - 2,或者我可以将它与列表一起使用,例如4 5 - 3 4,甚至可以做 3 4 5 - 1 这似乎将运算符的右侧“提升”为数组,即使我只是给它一个标量。

我假设后一种行为包含在 ch.1 中的这一行中。上述文字2:

Consequently, the two arguments of = must have the same shapes, (or at least, as in the example of Y=2, compatible shapes). Otherwise an error results.

确实,3 4 5 - 2 3 是一个错误。 “兼容形状”的技术定义是什么?它是像“相同的形状或标量”一样简单,还是还有更多内容?

最佳答案

来自词典页面B. Verbs :

Agreement. In the phrase p v q, the arguments of v must agree in the sense that one frame must be a prefix of the other

所以以下内容都可以工作

  (i. 2 3) * (i. 2 3 4)     NB. frame of left arg is prefix of the right arg
  (i. 2) * (i. 2 3 4)       NB. frame of left arg is prefix of the right arg
  (i. 2 3 4) * (i. 2 3)     NB. frame of right arg is prefix of the left arg

有关框架的正式定义,请参阅词典页面 A. Nouns

我推荐this section of J for C programmers作为对这些概念的全面覆盖。

关于arrays - J 动词的数组参数 "compatible shape"是什么构成的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8814295/

相关文章:

java - 我可以在 Java 中使用相同的指令声明和初始化数组吗?

python - 具有特定间隙的 numpy 排列

javascript - angularjs如何通过下划线或其他任何方式从数组中删除对象

powershell - 如何在 Powershell 中的一行中调用具有多个参数的多个参数?

list - J,找不到的动词

j - 将集合分成两个对

J : Iverson's `table` function from _A Personal View of APL_

javascript - 关于 Angular 2 - 从数组中提取变量(与前端 : html and component. ts 相关)

php - 调用参数不足的 PHP 函数有什么规则?

bash - 如何使用带参数的字符串来调用脚本,就像 bash 在解释命令行时所做的那样?