简体   繁体   English

如何重复J中表达式的求值?

[英]How to repeat the evaluation of an expression in J?

Given the following expression in J, how do I execute it n times? 给定J中的以下表达式,我该如何执行n次?

6?99

The only solution I could come up with was to turn it into a verb, which works nicely, but I suspect there's a better way: 我能提出的唯一解决方案是把它变成一个动词很好的动词,但我怀疑有更好的方法:

(3 : '6?99')"0 i.100

Now, before anyone gets confused, this question is not about the specific expression 6?99 . 现在,在任何人感到困惑之前,这个问题与6?99的具体表达无关 It is a general question about the J programming language. 这是关于J编程语言的一般问题。 Your answer should be general enough to apply to any J expression, not just 6?99 . 你的答案应该足够普遍,适用于任何 J表达式,而不仅仅是6?99

Still turning it into a verb, but this time tacitly 仍然把它变成一个动词,但这一次默默无闻

   (6 ? 99"_)"0 i.4
92 61 82  7 67 12
56 76 77 67  9 24
16 31  9 76 70 98
65 24  2 28  1 39

Depending on the verb this could be a little cleaner than explicit. 根据动词,这可能比显式更清晰。

The usual way of doing this would be to make copies of the left argument, but I sense that is not what you would be looking for? 通常的做法是复制左边的参数,但我觉得这不是你想要的东西吗?

   n=.4
   6 ? n $ 99
43 55 79 71 35 33
41 56 67  3 78 24
38 34  7 61 14 13
95 63 43 47 73 29

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM