If we compare

   0 ?@($&>)~ i.4
       0        0        0
0.607491        0        0
0.830036 0.522418        0
0.146366 0.234911 0.536014

with

   0 ?@:($&>)~ i.4
0.645516 0.0232939 0.0378971
0.865484  0.632304  0.360244
0.377852  0.564178  0.597046
0.801784  0.826119   0.12304

we should be able to recognize that in the first case the zero fill
padding happened after ? was used while in the second case it happens
before ? was used.

More specifically, in the first case, ? is used four times, like this:

   ? 0 $ 0
   ? 1 $ 0
   ? 2 $ 0
   ? 3 $ 0

And then the results are assembled into an array, so it's actually
more like this:

   (? 0 $ 0), (?1 $ 0), (?2 $ 0),: 3 $ 0

In the second case, ? is used once, like this:

   ? 4 3 $ 0

Does that help?

Do you see how these rephrasings correspond to the original expressions?

Thanks,

-- 
Raul



On Thu, Jul 7, 2016 at 11:32 AM, 'Pascal Jasmin' via Programming
<[email protected]> wrote:
> you meant this:
>
> 0 ?@:($&>~) i.4
>
> don't actually understand why ?@ is different though.
>
>
>
> ----- Original Message -----
> From: Raul Miller <[email protected]>
> To: Programming forum <[email protected]>
> Sent: Thursday, July 7, 2016 11:25 AM
> Subject: Re: [Jprogramming] Use of (@) 'Atop'
>
> (In case this is not obvious, I should note that you will need to add
> a pair of parenthesis to that example before the actual difference
> shows up.)
>
> --
> Raul
>
>
> On Thu, Jul 7, 2016 at 11:23 AM, Raul Miller <[email protected]> wrote:
>>    0 ?@$&>~ i.4
>>
>> Does that help?
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Thu, Jul 7, 2016 at 10:06 AM, 'Pascal Jasmin' via Programming
>> <[email protected]> wrote:
>>> I'd like to see an example.
>>>
>>>
>>>
>>>
>>> ----- Original Message -----
>>> From: Raul Miller <[email protected]>
>>> To: Programming forum <[email protected]>
>>> Sent: Thursday, July 7, 2016 9:59 AM
>>> Subject: Re: [Jprogramming] Use of (@) 'Atop'
>>>
>>> Only for this example.
>>>
>>> I can construct other examples where ?@ and ?@: give different results.
>>>
>>> Do you see why?
>>>
>>> Thanks,
>>>
>>> --
>>> Raul
>>>
>>>
>>> On Thu, Jul 7, 2016 at 9:35 AM, 'Pascal Jasmin' via Programming
>>> <[email protected]> wrote:
>>>> ? (2,y) $ 0 or u N v N
>>>>
>>>>
>>>> is more formally equivalent to
>>>>
>>>>
>>>>   (2,y)?@:$ 0  or N u@:v N
>>>>
>>>>
>>>> but because ? is a rank 0 verb, ?@ and ?@: will always give the same 
>>>> result.
>>>>
>>>>
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Martin Kreuzer <[email protected]>
>>>> To: [email protected]
>>>> Sent: Thursday, July 7, 2016 8:37 AM
>>>> Subject: [Jprogramming] Use of (@) 'Atop'
>>>>
>>>> Hi all -
>>>>
>>>> Approximating Pi using the Monte Carlo method (circle enscribed in
>>>> unit square) came up with
>>>>
>>>>     pia=. 13 : '(4 * y %~ +/ 1 >: +/ *: <: +: ? (2,y) $ 0)'("0)
>>>>     (pia 10^(4+i.3)) ,:(4+i.3)
>>>> 3.1524 3.1438 3.14106
>>>>       4      5       6
>>>>
>>>> I then compared my version with the J verb at Rosetta Code and the
>>>> only difference I found was the use of 'Atop':
>>>>
>>>> piMC=: monad define "0
>>>>     4* y%~ +/ 1>: %: +/ *: <: +: (2,y) ?@$ 0
>>>> )
>>>>
>>>> Q:
>>>> What is the advantage (in this particular case) of using 'Atop'..?
>>>>     ? (2,y) $ 0
>>>> vs
>>>>     (2,y) ?@$ 0
>>>>
>>>> Thanks
>>>> -M
>>>>
>>>> ----------------------------------------------------------------------
>>>> 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
> ----------------------------------------------------------------------
> 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