Actually, }. gets rid of the zeros, and we only go at most one less than the square root of y in that fragment.
,/ ,"0/~ }. i. <. %: 9 1 1 1 2 2 1 2 2 (1 less than the square root of y is ok because we are adding three numbers. two less than the square root of y would be a problem.) You got the basic functionality right, of course, and the slipped details would only matter in a re-implementation. (And I make mistakes at a similar rate.) But I thought this was worth noting. I should also add that throwing test data at a fragment of the code is a really good way of understanding it. This tends to work far better than adding more symbols for people to misunderstand, in my experience. Thanks, -- Raul On Thu, Nov 30, 2017 at 4:56 AM, Marshall Lochbaum <[email protected]> wrote: > Without any comments, and only the knowledge that it computes > Pythagorean triples, I was able to read and understand that code > completely in about four minutes. Reading line two right to left, I > decided the result was the primitive triples with sum less than or equal > to y just before getting to the word "prim". > > Do you consider the description "list the pairs of numbers which range > from zero to two less than the floor of the square root of y" to be > comprehensible? The code (,/ ,"0/~ }. i. <. %: y) says the same thing, > using essentially the same concepts, with symbols instead of words. > Sure, there could be a comment stating the English version (and there > should be on a site like RosettaCode), but it seems a little strange to > write the same thing a second time, in a less precise and more awkward > language. > > J is read a few primitives at a time, rather than a line at a time. This > might be frustrating to a programmer from another language since it > feels like less progress is being made. But it would be very superficial > to dismiss the language because of this, especially when the amount of > functionality that can be understood in the same amount of time is > greater with a little bit of experience. > > Regarding ease of use for beginners, I don't care whether the language > thrives. I care whether I personally can use it to understand and write > algorithms better. J has made many missteps from the former perspective > but very few from the latter. > > Marshall > > On Thu, Nov 30, 2017 at 03:46:00AM +0000, Dabrowski, Andrew John wrote: >> Yes, after reading my own description of my fascination with tacit I thought >> I sounded like a prick, so I'm trying to use explicit more, and it is nice: >> still concise, but easier to parse. >> >> One thing that irks me is the J solutions posted on Rosetta Code. Here's >> the one for Pythagorean triples. >> >> trips=:3 :0 >> 'm n'=. |:(#~ 1 = 2 | +/"1)(#~ >/"1) ,/ ,"0/~ }. i. <. %: y >> prim=. (#~ 1 = 2 +./@{. |:) (#~ y >: +/"1)m (-&*: ,. +:@* ,. +&*:) n >> /:~ ; <@(,.~ # {. 1:)@(*/~ 1 + y i.@<.@% +/)"1 prim >> ) >> >> >> >> Impressive, but isn't Rosetta Code a place more for showing off how elegant >> your language can be, rather than how incomprehensible? >> >> >> On 11/28/2017 11:45 PM, Rob Hodgkinson wrote: >> >> Further on this comment Andrew, don’t get bogged down in the topic of tacit, >> you can get a lot of benefit form using J in native or explicit form and >> leave tacit for later. >> >> I have been programming in array languages for many years and also confess >> to being mesmerised by some of the tacit expressions which I do not find >> immediately readable at all, especially when peppered with ASCII like >> punctuation. >> >> Dissect certainly helps, but coding tacit for tacit’s sake is not something >> I get hung up about, you can derive huge benefit without it, but it can be >> nice to use when it becomes more familiar to you, as people show here when >> they create a group of small compact verb trains (or phrases) which together >> make a compact solution. >> >> Rob Hodgkinson >> >> >> >> On 29 Nov 2017, at 8:38 am, Andrew Dabrowski >> <[email protected]><mailto:[email protected]> wrote: >> >> >> >> As a beginner I find it impossible to parse a moderately sized tacit >> expression. No doubt one gets better at this, but like all computer >> languages, the one dimensional space it lives in seems to confound any >> attempts to represent mathematical ideas directly. >> >> >> >> A computer language based on mathematical notation sounds like a cool but >> impractical idea. It would to have to be 2 dimensional, as in fact math >> notation is. >> >> >> >> ---------------------------------------------------------------------- >> 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
