Define a verb Centigrade in J programming

100 Views Asked by At

When defining the verb centigrade to convert its argument from a Fahrenheit to a centigrade, the code in the book 'J Primer' is:

   centigrade =. 3 : 0
t1 =. y. - 32
t2 =. t1 * 5
t3 =. t2 % 9
)

However, I had the spelling error in 'y.' part. But when I type 'y' instead of 'y.' in the definition, it works.

   centigrade =. 3 : 0
t1 =. y - 32
t2 =. t1 * 5
t3 =. t2 % 9
)

Why is that? Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

Originally, the J language used x. and y. for the internal arguments to an explicit verb. You can reset to allow for y. or x. if you want to use legacy code by using the foreign conjunction 9!:49

9!:49 [ 0 for not accepting y. 9!:49 [ 1 for accepting y. 9!:48 '' gives the current status of the flag. http://www.jsoftware.com/help/dictionary/dx009.htm (bottom of page)

   test=: 3 : 'x. + y.'
|spelling error
|   x. + y.
|   ^
|   test=:3     :'x. + y.'
   9!:49 [ 1

   test=: 3 : 'x. + y.'
   9!:49 [ 0

   test=: 3 : 'x. + y.'
|spelling error
|   x. + y.
|   ^
|   test=:3     :'x. + y.'