It seems to me that 13 : is correct and 3 : is wrong.
Both are dealing with random numbers.
See the difference between two runs of shuf and I .
Shuf is random each time (??) and I is random once (?.) until it is run
again.
shuf=: 13 :'<"2|."2 y {~ /:~"1 (|.x)$?~*/|.x'
i=: 13 :'<"2 x({~ ([: \:"1~ |. $ [: ?.~ */))~y'
(13 4 shuf deck);' ';<13 4 shuf deck
┌─────────────┬───┬─────────────┐
│┌──┬──┬──┬──┐│ │┌──┬──┬──┬──┐│
││♠K│♠A│♠Q│♠4││ ││♠A│♠J│♠K│♠Q││
││♠J│♠6│♠9│♥A││ ││♠9│♠6│♠4│♠T││
││♠T│♠5│♠8│♥Q││ ││♠7│♠5│♥K│♠8││
││♥6│♠3│♠7│♥7││ ││♠3│♠2│♥9│♥Q││
││♥5│♥J│♠2│♥2││ ││♥A│♥T│♥7│♥J││
││♥4│♥T│♥K│♦T││ ││♥4│♥8│♥5│♥2││
││♦K│♥3│♥9│♦4││ ││♦A│♥6│♦Q│♦6││
││♦J│♦Q│♥8│♣K││ ││♦8│♥3│♦J│♦2││
││♦7│♦6│♦A│♣J││ ││♦7│♦K│♦T│♣K││
││♦3│♦5│♦9│♣8││ ││♦4│♦9│♦5│♣9││
││♣A│♣9│♦8│♣5││ ││♣J│♣A│♦3│♣7││
││♣Q│♣7│♦2│♣4││ ││♣T│♣5│♣Q│♣6││
││♣T│♣3│♣6│♣2││ ││♣4│♣2│♣8│♣3││
│└──┴──┴──┴──┘│ │└──┴──┴──┴──┘│
└─────────────┴───┴─────────────┘
(13 4 i deck);' ';<13 4 i deck
┌─────────────┬───┬─────────────┐
│┌──┬──┬──┬──┐│ │┌──┬──┬──┬──┐│
││♠K│♠A│♠J│♥Q││ ││♠K│♠A│♠J│♥Q││
││♠4│♠Q│♠T│♥8││ ││♠4│♠Q│♠T│♥8││
││♥A│♠8│♠9│♥6││ ││♥A│♠8│♠9│♥6││
││♥T│♠6│♠7│♥4││ ││♥T│♠6│♠7│♥4││
││♥2│♠5│♠3│♥3││ ││♥2│♠5│♠3│♥3││
││♦T│♥K│♠2│♦A││ ││♦T│♥K│♠2│♦A││
││♦5│♥J│♥9│♦K││ ││♦5│♥J│♥9│♦K││
││♦4│♥7│♥5│♦Q││ ││♦4│♥7│♥5│♦Q││
││♦2│♦J│♦8│♦7││ ││♦2│♦J│♦8│♦7││
││♣Q│♦9│♦6│♣9││ ││♣Q│♦9│♦6│♣9││
││♣T│♣A│♦3│♣8││ ││♣T│♣A│♦3│♣8││
││♣3│♣K│♣J│♣7││ ││♣3│♣K│♣J│♣7││
││♣2│♣6│♣5│♣4││ ││♣2│♣6│♣5│♣4││
│└──┴──┴──┴──┘│ │└──┴──┴──┴──┘│
└─────────────┴───┴─────────────┘
-----Original Message-----
From: Programming <[email protected]> On Behalf Of Linda
Alvord
Sent: Sunday, October 21, 2018 4:51 AM
To: [email protected]
Subject: Re: [Jprogramming] Using rank to avoid looping - reference?
Not yet.
e=. 13 : 'T - T=. ?y'
> e 10+i.7
_1 _1 0 _7 _10 4 _6
ee=. 3 : 'T - T=. ?y'
> > ee 10+i.7
0 0 0 0 0 0 0
Linda
-----Original Message-----
From: Programming <[email protected]> On Behalf Of Linda
Alvord
Sent: Sunday, October 21, 2018 4:04 AM
To: [email protected]
Subject: Re: [Jprogramming] Using rank to avoid looping - reference?
Martin, it seems to be fixed.
vb=: 13 :'+:y'
]A=:vb i.21
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
dc=: 13 :'".vb=:''+:y'''
dc
3 : '".vb=:''+:y'''
]B=:dc i. 21
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
A-:B
1
Linda
-----Original Message-----
From: Programming <[email protected]> On Behalf Of Raul
Miller
Sent: Thursday, October 18, 2018 11:03 AM
To: Programming forum <[email protected]>
Subject: Re: [Jprogramming] Using rank to avoid looping - reference?
Anything that can produce different results at different times can be "changed"
by 13 : to produce a result obtained when it was running.
For example: 13 :'fread ''file.txt'''
--
Raul
On Wed, Oct 17, 2018 at 6:30 PM Jose Mario Quintana
<[email protected]> wrote:
>
> I am aware that executing code with ". relying on explicit context can
> trip
> 13 : , for instance,
>
> u=. 3 : '".''+:y'''
>
> u 5
>
> 10
>
> v=. 13 : '".''+:y'''
>
> v 5
>
> 2
>
> v
>
> 2:
>
> I am not quite sure but probably there are more glitches, according
> to,
>
> NuVoc 13 :
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcode
> .jsoftware.com%2Fwiki%2FVocabulary%2Fcom%23m13&data=02%7C01%7C%7C2
> dac8c6ed7084eedcedf08d6350ad08d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1
> %7C0%7C636754717892231673&sdata=WBCGWG87XTSaLHVUUIIcPTo%2B98z4CrUm
> LdDC7cCmhx8%3D&reserved=0
>
> "If you get exotic, you may encounter a bug or two in the
> implementation of 13 :"
>
>
>
> On Wed, Oct 17, 2018 at 1:39 PM Martin Kreuzer <[email protected]> wrote:
>
> > José -
> >
> > Thanks for pointing out that issue in the first place.
> >
> > I wasn't aware of the compiler module being overzealous sometimes ...
> >
> > Are there any other known (I'm fighting for words, might I call
> > them) 'glitches' comparable to this one, and where would they be
> > documented for lookup..?
> >
> > -M
> >
> > At 2018-10-17 16:25, you wrote:
> >
> > >Martin,
> > >
> > >In my example, using + instead of -, u was the double of a single
> > >roll and v was the sum of two "independent" rolls.
> > >
> > >Yours is a far better example for illustrating the issue,
> > >
> > > ( u=. 3 : ' T - (T=. ? y)' )
> > >3 : ' T - (T=. ? y)'
> > >
> > >u is one roll minus itself which produces zeroes; whereas
> > >
> > > ( v=. 13 : ' T - (T=. ? y)' ) ? - ?
> > >
> > >is the difference of two "independent" rolls.
> > >
> > >Thus, for example,
> > >
> > > u 0 0 0 0 0
> > >0 0 0 0 0
> > >
> > >whereas,
> > >
> > > v 0 0 0 0 0
> > >_0.0389238 0.321837 0.0862073 0.552116 _0.134629
> > >
> > >Thanks! I had one of those moments after I read your posts... Why
> > >did I not think of that? :)
> > >
> > >
> > >On Wed, Oct 17, 2018 at 8:08 AM Martin Kreuzer
> > ><[email protected]>
> > wrote:
> > >
> > > > Addendum:
> > >
> > > > Consider, in contrast, the behaviour of this *explicit* definition:
> > >
> > > > ee=. 3 : 'T - T=. ?y'
> > > > ee 10+i.7
> > > > 0 0 0 0 0 0 0
> > >
> > > > Same result as working *outside* a verb definition:
> > >
> > > > ] T=. ? 10+i.7
> > > > 6 6 0 9 12 1 5
> > > > T - T
> > > > 0 0 0 0 0 0 0
> > >
> > > > -M
> > >
> >
> >
> ----------------------------------------------------------------------
> For information about J forums see
> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.j
> software.com%2Fforums.htm&data=02%7C01%7C%7C2dac8c6ed7084eedcedf08
> d6350ad08d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63675471789223
> 1673&sdata=C2Q4einbAU%2Fg3IEEznT7HdEBef1HGG7972eu0KfmFJw%3D&re
> served=0
----------------------------------------------------------------------
For information about J forums see
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C5115ff6419ce4a64688d08d637324ede%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636757086535503397&sdata=hB9pUhlCGzCdY2lV%2FrfmrvdP8P6JcxT9FfFH9GxgOls%3D&reserved=0
----------------------------------------------------------------------
For information about J forums see
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C5115ff6419ce4a64688d08d637324ede%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636757086535503397&sdata=hB9pUhlCGzCdY2lV%2FrfmrvdP8P6JcxT9FfFH9GxgOls%3D&reserved=0
----------------------------------------------------------------------
For information about J forums see
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C5115ff6419ce4a64688d08d637324ede%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636757086535503397&sdata=hB9pUhlCGzCdY2lV%2FrfmrvdP8P6JcxT9FfFH9GxgOls%3D&reserved=0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm