Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to repeat the evaluation of an expression in J?

Tags:

j

Given the following expression in J, how do I execute it n times?

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. It is a general question about the J programming language. Your answer should be general enough to apply to any J expression, not just 6?99.

like image 312
Gregory Higley Avatar asked Feb 02 '18 12:02

Gregory Higley


People also ask

How do you evaluate an expression explain with example?

To evaluate an algebraic expression, you have to substitute a number for each variable and perform the arithmetic operations. In the example above, the variable x is equal to 6 since 6 + 6 = 12. If we know the value of our variables, we can replace the variables with their values and then evaluate the expression.

How do you evaluate an expression in C?

In the C programming language, an expression is evaluated based on the operator precedence and associativity. When there are multiple operators in an expression, they are evaluated according to their precedence and associativity.

What is expression evaluation?

To evaluate an algebraic expression means to find the value of the expression when the variable is replaced by a given number. To evaluate an expression, we substitute the given number for the variable in the expression and then simplify the expression using the order of operations.

Which one is the basic method to evaluate an operator?

The evaluation operator (=) EQUAL SIGN is used to evaluate a variable, function, or expression numerically. The Boolean equal to operator (=) CTRL+EQUAL SIGN is used to evaluate the equality condition in a Boolean statement. It is also used for programming, solving, and in symbolic equations.


1 Answers

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
like image 70
bob Avatar answered Oct 03 '22 16:10

bob