I have attached a j script which will provide the same results in Jjhs as those shown below. In the years I have used APL and J, I have focused on the use of the notation as a natural way of thinking about mathematical concepts. Couple this with the executable results of the thinking. To me, this is the most vital aspect of the notation. If, in the long run it produces better programmers, that is a bonus.
So, I would appreciate any improvements that could be made in the first response I have planned as a response to Challenge 8, the creation of a Shamrock. In this, I focus on the aspect of mathematics that applies to graphs. Every point within the equation of a circle satisfies this equation. (This mixes a little conventional notation and some J for "less than or equal or to" the radius squared.) 2 2 2 X + y <: r Using explicit definitions are the best way I know to produce results that emphasize this concept. However, seeing the tacit expressions (which appear to be working as I intended them to work) are a way to lead students to a more sophisticated way to use J as a programmer. NB. ic is mask for inside the circle NB. sy is conversion to symbols NB. gf expands symbols for grapefruit tree NB. exdwl David Ward Lambert expands symbols with special code ]y=:_5+i.11 _5 _4 _3 _2 _1 0 1 2 3 4 5 ic=: 13 :'(>./y)>:%:(y^2)+/y^2' ic >./ >: [: %: (2 ^~ ]) +/ 2 ^~ ] ic y 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 sy=: 13 : '((ic y)+(ic y)*?1+10*ic y) {x' NB. For some reason I can't replace 10 with _2+$c sy [ {~ ([: ic ]) + ([: ic ]) * [: ? 1 + 10 * [: ic ] c=:' ||\\//OOOOO' $c 12 c sy y | /|\|OO| |/OOOOO\O O/OO|O/|\ |O|O\\|O\ O|/O/|/OO\| /\O/|\OO\ O/|OOOO/O OO\|\\O/\ |\O\/O\ | gf=: 13 :'|.,"2 |:(x sy y),:"2'' ''' gf [: |. [: ,"2 [: |: ' ' ,:"2~ sy c gf y O O O \ / \ / \ | O \ \ O O O O O O O O O O \ O / O | O O O \ \ | O O \ O / O O / O O O O O \ O / \ O | / O / O O O O O O O O O O / \ \ O \ O O O \ \ O O \ | | \ exdwl=: 13 :'1j1&#"1 x sy y' exdwl [: 1j1&#"1 sy c exdwl y O O O / | / O O \ \ | \ O O \ | O / O O / / / O O \ \ O / / O | / O O | | / \ / \ O / O / O \ \ \ | O O O | \ / \ O O \ | \ O \ O O O O O O | O / \ O \ | / / / O This is a "grapefruit tree" seen from an airplane. David Ward Lambert provided his improvement to the final function which will be a challenge for programmers. Since there are some who would discourage the use of 13 : I would appreciate a way that is as transparent as this for mathematics educators (one of the groups Ken Iverson sought to attract). Please give some thought to students in early stages of Algebra, and find a way to give them a real feeling for the equation of a "painted circle" on the Cartesian plane. I'd enjoy seeing better alternatives. Linda -----Original Message----- From: programming-boun...@jsoftware.com [mailto:programming-boun...@jsoftware.com] On Behalf Of Raul Miller Sent: Monday, March 19, 2012 4:11 PM To: Programming forum Subject: Re: [Jprogramming] why=: 13 :'y*y*y' For what it's worth, J's problem with 13 :'y+y' is probably something like: original y+y made tacit +~ simplified + In other words, since + is commutative, the ~ is "unnecessary". Except, of course, that's only relevant for expressions like 13 :'x+y' So, anyways, I expect that the problem is that the rule that supports simplification for commutative expressions has lost the context that would be necessary to know that it's applicable. If I am right, the simple solution would be to remove that simplification when the arguments are not available (which might be always). -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm