                                   Chapter 2

                          DIFFERENCES BETWEEN MACHINES


      a j question and problem
      Factorials in J


*========================================
# a j question and problem

+------------------
| Eythan Weg
| <WEG.91Oct8182431@mace.cc.purdue.edu>

Can someone make sense of the following fragment on a vax?

   axis
+-----------------------------+-++
|(1{y.)+(i.>:0{y.)*%~`(-~)/y. |:||
+-----------------------------+-++
   simpson
+------------------------------------------------+-+-+
|x=.axis y.                                      |:|2|
|(3%~(%~)`(-~)/y.)*+/(1|. 1 1 ,(<:0{y.)$4 2)*x. x| | |
+------------------------------------------------+-+-+

   ^ simpson 4 0 1
1.71832


l1=.'z=.x.f. simpson (4,2{.y.)'
     rec=.l1 : 2
   rec
+-------------------------+-+-+
|z=.x.f. simpson (4,2{.y.)|:|2|
+-------------------------+-+-+

^rec 0 1 4
   1.71832
   l1=.'z=.x. simpson (4,2{.y.)'
     rec=.l1 : 2
   ^rec 0 1 4
Memory fault - core dumped
$

Thanks,


+------------------
| Sam Sirlin
| <1991Oct9.171353.10409@csi.jpl.nasa.gov>


In article <WEG.91Oct8182431@mace.cc.purdue.edu>, weg@mace.cc.purdue.edu (Eythan
 Weg) writes:
]> Can someone make sense of the following fragment on a vax?
]>
]>    axis
]> +-----------------------------+-++
]> |(1{y.)+(i.>:0{y.)*%~`(-~)/y. |:||
]> +-----------------------------+-++
]>    simpson
]> +------------------------------------------------+-+-+
]> |x=.axis y.                                      |:|2|
]> |(3%~(%~)`(-~)/y.)*+/(1|. 1 1 ,(<:0{y.)$4 2)*x. x| | |
]> +------------------------------------------------+-+-+
]>
]>    ^ simpson 4 0 1
]> 1.71832

How did this happen? At this point I get a value error (Sun sparc).
the monadic form of "simpson" uses x., which doesn't make sense.


]> Memory fault - core dumped

My favorite is still
   2=<2
Bus error
>
[[NB. sws.  it's fixed now, at least on my sun sparc]]


+------------------
| Sam Sirlin
| <1991Oct10.015138.14179@csi.jpl.nasa.gov>

In article <WEG.91Oct8182431@mace.cc.purdue.edu>, weg@mace.cc.purdue.edu (Eythan
 Weg) writes:
]> Can someone make sense of the following fragment on a vax?

]>    ^rec 0 1 4
]> Memory fault - core dumped
]> $

Hmm, if I define simpson as a conjunction (as pointed out by Raul
Deluth Miller-Rockwell - how do you tell the difference from a printed
record?), then I get essentially the same bug on a Sun sparc -

   ^rec 0 1 4
Segmentation fault
kalessin{sam} >


+------------------
| Peter S. Shenkin
| <1991Oct10.161942.7706@ctr.columbia.edu>

In article <1991Oct9.171353.10409@csi.jpl.nasa.gov> sam@csi.jpl.nasa.gov (Sam
 Sirlin) writes:
>My favorite is still
>   2=<2
>Bus error

How about:
   2/2
Segmentation fault (core dumped)

under J-2.9 on a Personal Iris.

Can anyone do this with only two characters?    :-)

[[NB. sws.  This is also ok on my sparc now ]]


+------------------
| Roger Hui
| <1991Oct12.035226.9823@yrloc.ipsa.reuter.COM>


Eythan Weg writes of J/VAX:
>    axis
> +-----------------------------+-++
> |(1{y.)+(i.>:0{y.)*%~`(-~)/y. |:||
> +-----------------------------+-++
>    simpson
> +------------------------------------------------+-+-+
> |x=.axis y.                                      |:|2|
> |(3%~(%~)`(-~)/y.)*+/(1|. 1 1 ,(<:0{y.)$4 2)*x. x| | |
> +------------------------------------------------+-+-+
>    ...
>
>    l1=.'z=.x. simpson (4,2{.y.)'
>    rec=.l1 : 2
>    ^rec 0 1 4
> Memory fault - core dumped

Sam Sirlin writes of a similar problem on J/Sun4:
>    ^rec 0 1 4
> Segmentation fault

These are manifestations of a user-defined infinite recursion
more simply demonstrated by:

   conj =. 'x. 3' : 2
   'x.'~ conj +

I will fix the system to report the problem more gracefully than
by crashing.

[[NB. sws.  I get for this:
    'x.'~ conj +
limit error
[0] x. 3
]]

Sam Sirlin writes of J/Sun4:
> My favorite is still
>    2=<2
> Bus error

Inspection of the source reveals that the logic is such that on some
machines (and it looks like on the Sun4) a memory fault or bus error
could result.  (I am not certain because I don't have ready access to
a Sun4 to try this now.)  I think I have now fixed this error, and the
fix will be distributed with J 3.5 and subsequent versions.  Thank you
for reporting this error (and sorry for ruining your favorite bug :-).

Peter Shenkin writes of J 2.9/SGI:
> How about:
>    2/2
> Segmentation fault (core dumped)
>
> under J-2.9 on a Personal Iris.

The phrase 2/2 correctly signals domain error on J 3.4/PC, and inspection
of the source reveals no obvious reason why the behaviour should be
different on other machines.  It is possible that the error has been
fixed since J-2.9/SGI (the last available version at Waterloo is J 3.2/SGI).
When I next have access to an SGI I will try this.



*========================================
# Factorials in J

+------------------
| Simpson David Grant
| <1991Mar9.040541.28914@aplcen.apl.jhu.edu>


Can someone explain what is happening when I try to calculate
factorials in the following J session?  I do this right after
starting up J (version 3):

   !9
362880
   !174
1.7=e309
   !9
1

All following attempts to calculate factorials also produce 1.
What gives?

[[NB. sws.  this should have been fixed with the addition of infinity ]]


+------------------
| Sam Sirlin
| <1991Mar11.202526.20774@jato.jpl.nasa.gov>

In article <1991Mar9.040541.28914@aplcen.apl.jhu.edu>, simpson@aplcen.apl.jhu.
edu (Simpson David Grant) writes:
]> In article <1991Mar9.040541.28914@aplcen.apl.jhu.edu>, simpson@aplcen.apl.
jhu.edu (Simpson David Grant) writes:
]>
]> Can someone explain what is happening when I try to calculate
]> factorials in the following J session?  I do this right after
]> starting up J (version 3):
]>
]>    !9
]> 362880
]>    !174
]> 1.7=e309
]>    !9
]> 1
]>
]> All following attempts to calculate factorials also produce 1.
]> What gives?
]>
]>                                  David Simpson

What version/machine? With 2.9 on my SPARC 1 I get:


   !9
362880
   !174
_
   !9
362880
   !4
24


which looks fine. Version 2.4 on my PCAT bombs when it trys !174 (overflow).
Sounds like infinity doesn't quite work in your version.


+------------------
| Simpson David Grant
| <1991Mar13.042856.23984@aplcen.apl.jhu.edu>

>]> In article <1991Mar9.040541.28914@aplcen.apl.jhu.edu>, simpson@aplcen.apl.
jhu.edu (Simpson David Grant) writes:
>]>
>]> Can someone explain what is happening when I try to calculate
>]> factorials in the following J session?  I do this right after
>]> starting up J (version 3):
>]>
>]>    !9
>]> 362880
>]>    !174
>]> 1.7=e309
>]>    !9
>]> 1

>]> All following attempts to calculate factorials also produce 1.
>]> What gives?
>]>
I got these results with J version 3 for the PC, running on my
Zeos 386.  I tried this same software today on an IBM AT (80286)
with different results -- it hangs the computer for !174, but
does not answer "1" for every factorial like my 386 does.


+------------------
| Sam Sirlin
| <1991Mar13.184033.25957@jato.jpl.nasa.gov>

In article <1991Mar13.042856.23984@aplcen.apl.jhu.edu>, simpson@aplcen.apl.jhu.
edu (Simpson David Grant) writes:

]> I got these results with J version 3 for the PC, running on my
]> Zeos 386.  I tried this same software today on an IBM AT (80286)
]> with different results -- it hangs the computer for !174, but
]> does not answer "1" for every factorial like my 386 does.
]>

I tried this in version 2.9 on IBM PCAT and Everex 386. The pc version
of 2.9 doesn't have infinity, and both machines give domain errors for
factorial arguments > 170, but work fine afterwards. Maybe you should
grab 2.9 from watserv. The sun4 version of 2.9 seems to have a limited
implementation of infinity.


+------------------
| Roger Hui
| <1991Mar19.061927.28265@yrloc.ipsa.reuter.COM>

_ (infinity) is not yet available, and this is indicated as
such in the status.doc file.  It is not yet available because
(a) the implications of _ are pervasive and (b) there is uneven
hardware and C compiler support for _.

Nevertheless, !174 should have failed more gracefully than it did.
If you'd tell me the machine and the J version, it would help me
a great deal in tracking down this error.  (J runs on over a dozen
different machines.  On a given error, the possibilities are numerous:
it happens on all versions; it happens on only some machines; it is
my error; it is a C compiler bug; etc. etc. etc.)

[[NB. sws.  _ seems to work now, at least on suns.]]


 