The problem may be that the other program is designed to handle the grade school "BEDMAS" heirarchy, while J (and APL) do right to left execution so to deal with this it would be necessary to simulate BEDMAS. In this case it would need to look at a*b and b*a before considering +. Note that students using calculators often do err in the other direction a*b +b*a =((a*b)+b)*a=18 because the calculators take entries as given- and calculators are "always correct" .Computers do what they are told and do not read minds to determine that you have told them what you actually wanted done. This can happen in J as well. a* b+b*a =a*(b+(b*a)=18
In this case the same resultant error.

It really comes down to what you have said-the programmer has to express the results clearly. What might be needed is an expression transform verb that essentially mimics BEDMAS or whatever logic is used for the symbolic calculations

.

On 01/08/2013 10:05 AM, bob therriault wrote:
Hi Eelvex,

Sounds as if the challenge is whether the other program can provide a 
parenthesized version of the symbolic calculations. If it has something along 
the lines of J's parenthesized view (5!:6) , then that would allow the result 
to be interpreted unambiguously. If the symbolic manipulator can't express the 
results clearly, that would be where you come in. :)

Cheers, bob

On 2013-08-01, at 9:40 AM, EelVex wrote:

Hi bob,
that's the problem (I think I was not clear): I want to read the output
from another program that makes symbolic calculations and I don't want to
have to read huge expressions just to parenthesise them correctly.


On Thu, Aug 1, 2013 at 7:31 PM, bob therriault <[email protected]>wrote:

Hi Eelvex,

I think that the monadic primitive Do (".) may be the answer, although you
would need to use parenthesis to get the order of execution that you would
like.

   a=.2
   b=.3
   ".'a*b+b*a'
18
   ".'(a*b)+b*a'
12

Cheers, bob

On 2013-08-01, at 9:22 AM, EelVex wrote:

Is there a verb in the library to read "paper math" into J expressions?

Eg.
  a =: 2
  b =: 3
  read 'a * b + b * a'
12
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to