Thanks, Raul and Henry. The precision…! How silly of me. Serendipitous, though. Way back in June last year I undertook to write-up the "Empty Lists?" thread for NuVoc, which started with a deceptively simple question and grew to 55 contributions, http://www.jsoftware.com/pipermail/programming/2017-June/047555.html I haven't forgotten, but the task has only just bubbled to the surface of my groaning in-tray. (…And I thought I'd retired!)
I'll leave it to someone else to provide the answer to your puzzle, Henry – it'll be instructive. My task at the end of the day will be to untuck such arcana from their shady corners of NuVoc. Just in case anyone is tempted to dismiss it all as the J version of how many angels can fit on a pinhead, I'll retort that – indeed – few people need to worry when they're building data structures – unless they're bold enough to write utilities destined for stdlib. But people put a lot less thought into their conditional statements than they do their prime data structures. That's where some pretty gamey nouns can arise and sow a bug farm. A trivial example which often defeats beginners: if. reply = 'yes' do. … -and it often seems to work. Up to a point…! Me too. All too rarely do I write a conditional statement where what's sandwiched between if. and do. is guaranteed to be a Boolean scalar. Then I touch it up later to fix a bug and – hey presto! – two more appear. On Fri, Jan 12, 2018 at 10:32 AM, Henry Rich <[email protected]> wrote: > They don't remember their parentage - they have different precisions. Add > them together or apply (,) between them and only one precision can survive. > > I think there is little practical difference. (1000000000 $ y) will take > a lot more space with one than the other. Some special combinations only > apply to Booleans. Some operations (x * y for example) go faster when one > argument is Boolean. > > PUZZLE: > > There is one tiny way that the difference can become significant, i. e. > can change the type (not just the precision) of a result. Can you find it? > The answer is in NuVoc, but tucked away in a corner! > > Henry Rich > > > On 1/12/2018 12:06 AM, Ian Clark wrote: > >> For years I've laboured under the delusion that nouns (i.0) and (0$0) are >> identical in all respects, and will pass any tests designed to >> discriminate >> between them. >> >> However 5!:5 can tell the difference: >> >> 5!:5 <'z' [z=: i.0 >> >> i.0 >> >> 5!:5 <'z' [z=: 0$0 >> >> 0$0 >> >> >> Nor, it seems, is there any fooling it: >> >> 5!:5 <'z' [z=: 5}.5{.i.0 >> >> i.0 >> >> 5!:5 <'z' [z=: 6}.5{.i.0 >> >> i.0 >> >> 5!:5 <'z' [z=: 5}.5{.0$0 >> >> 0$0 >> >> 5!:5 <'z' [z=: 6}.5{.0$0 >> >> 0$0 >> >> >> How does 5!:5 know? Is this Just One of Those Things? Or is there some >> deliberate logic behind this subtle difference between (0$0) and (i.0)? >> Does this difference emerge in other ways – ones which might impact >> practical tasks? >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > > --- > This email has been checked for viruses by AVG. > http://www.avg.com > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
