J@没有按预期工作

发布于 2024-07-26 02:25:38 字数 197 浏览 3 评论 0原文

我刚刚开始尝试学习 J 语言,并对以下内容感到困惑:

   1 2 +/@{ i.4
1 2
   +/ 1 2 { i.4
3

当 @ 的文档中显示:“xu@vy ↔ uxv y”时,

我认为我只是将某个词性误认为是另一个,但也无法弄清楚

,我如何判断一个名字是什么类型的演讲?

I'm just starting to try to pick up the J language, and am confused by the following:

   1 2 +/@{ i.4
1 2
   +/ 1 2 { i.4
3

when in the documentation for @ it says: "x u@v y ↔ u x v y"

I assume I'm just mistaking one part of speech for another, but can't figure it out

also, how do I tell what type of speech a name is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

许一世地老天荒 2024-08-02 02:25:38
   NB. u b. 0 returns the rank of u
   NB. the rank of a verb determines the arguments it applies to at a time
   NB. monadic + y applies to atoms; dyadic x + y applies to pairs of atoms
   + b. 0
0 0 0
   NB. monadic +/ y and dyadic x +/ y apply to anything (unbounded rank)
   +/ b. 0
_ _ _
   NB. monadic { y applies to arrays of atoms;
   NB. dyadic x { y applies to pairs of atoms and anything
   { b. 0
1 0 _
   NB. u @ v has the rank of v
   +/@{ b. 0
1 0 _
   NB. since 1 2 { i.4 returns atoms at a time, +/ works on atoms
   +/"0 [ 1 2 { i.4
1 2
   NB. u @: v has unbounded rank
   +/@:{ b. 0
_ _ _
   NB. +/ applies to all of 1 2 { i.4 at once
   +/"_ [ 1 2 { i.4
3

   NB. mechanical translation to tacit form
   13 : '+/ x { y'
[: +/ {
   NB. u b. 0 returns the rank of u
   NB. the rank of a verb determines the arguments it applies to at a time
   NB. monadic + y applies to atoms; dyadic x + y applies to pairs of atoms
   + b. 0
0 0 0
   NB. monadic +/ y and dyadic x +/ y apply to anything (unbounded rank)
   +/ b. 0
_ _ _
   NB. monadic { y applies to arrays of atoms;
   NB. dyadic x { y applies to pairs of atoms and anything
   { b. 0
1 0 _
   NB. u @ v has the rank of v
   +/@{ b. 0
1 0 _
   NB. since 1 2 { i.4 returns atoms at a time, +/ works on atoms
   +/"0 [ 1 2 { i.4
1 2
   NB. u @: v has unbounded rank
   +/@:{ b. 0
_ _ _
   NB. +/ applies to all of 1 2 { i.4 at once
   +/"_ [ 1 2 { i.4
3

   NB. mechanical translation to tacit form
   13 : '+/ x { y'
[: +/ {
窗影残 2024-08-02 02:25:38

在我的偏见中,维基百科对排名以及它在 J 中“语音”的不同部分的上下文中的含义进行了不错的描述。

但是为了回答最初的问题,J 的跟踪工具对于理解其语法如何很有用有效:

   require'trace'
   trace '1 2 +/@{ i.4'

这将引导您逐步完成解析过程,显示每个产生规则所消耗的单词以及每个产生的结果。

Wikipedia has, in my biased opinion, a decent writeup on rank, and what it means in the context of the different parts of "speech" in J.

But to answer the original question, J's trace facility can be useful for understanding how its grammar works:

   require'trace'
   trace '1 2 +/@{ i.4'

This will take you step by step through the parsing process, showing the words being consumed by each production rule and the result each generates.

薄荷→糖丶微凉 2024-08-02 02:25:38

啊,我想我可能已经弄清楚了,我需要使用@:而不是@,

   1 2 +/@:{ i.4
3

这就是我想要的。 我想我得再读一些关于等级的内容,这是@和@之间的唯一区别:

Ah, I think I may have figured it out, I need to use @: instead of @

   1 2 +/@:{ i.4
3

which is what I wanted. Guess I'm going to have to read up some more on rank, which is the only difference between @ and @:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文