> If anyone can provide any other good illustrations of this, I'd be > grateful.
http://www.jsoftware.com/jwiki/Essays/99_Bottles_of_Beer http://www.jsoftware.com/jwiki/Essays/Kakuro http://www.jsoftware.com/jwiki/Essays/N_Queens_Problem http://www.jsoftware.com/jwiki/Essays/Self-Upgrading_Permutations http://www.jsoftware.com/jwiki/Essays/Sudoku http://www.jsoftware.com/jwiki/Essays/Triangular_Matrix_Inverse etc. Also, don't forget the simple examples which we take for granted because they are so old hat: avg=: +/ % # x=: 3 4 5 [EMAIL PROTECTED] 100 avg x NB. average of the planes avg"3 x NB. same as above avg"2 x NB. averages of the rows avg"1 x NB. averages of each row t=: 70 +/\ 0.5*_0.5+1000 [EMAIL PROTECTED] 0 NB. simulated daily close 30 avg\ t NB. 30-day moving average 200 avg\ t NB. 200-day moving average ((k-1)}.t) I.@:> k avg\t [ k=: 30 NB. indices where daily close is above k-day moving average ----- Original Message ----- From: Devon McCormick <[EMAIL PROTECTED]> Date: Wednesday, June 20, 2007 9:10 am Subject: Array vs. Looping examples [was Re: [Jgeneral] J Primer - naive implementation of add 2 lists of numbers] > Terrence Brannon wrote: > > > RE: http://www.jsoftware.com/help/primer/basic_list_adding.htm > > > > I think it would be nice to poke people's memory with a > for_item. based > example > > instead of just using while. > > Maybe it would be nice to preface this example ( > http://www.jsoftware.com/help/primer/basic_list_adding.htm) > with big red letters saying "DON'T DO THIS". > > At least the text ought to > provide a hint early on that "the way one would do this in BASIC" is > ridiculously > complicated compared to how we do this in J, i.e. point out that the > page following > (http://www.jsoftware.com/help/primer/j_list_adding.htm) this one > obviateseverything on it. > > I am now working on a paper for APL2007 in which I hope to provide > examplesof the clarity loopless > programming provides compared to the more conventional variety - > the "list > adding" page might well > serve as a simple example of this. However, this case is so > simple it is > vulnerable to the "array operations > are _only_ syntactic sugar" argument. > > Other examples I'm thinking of using are: showing how the first > six chapters > of the book > "Accelerated C++" (by Koenig and Moo) can be rendered in perhaps > six lines > of J, and a potential > re-write of a Markov Chain example (see "shaney.py" at > http://www.strout.net/python/tidbits.html) > in an array fashion. (See also > http://en.wikipedia.org/wiki/Mark_V_Shaney). > If anyone can provide any other good illustrations of this, I'd be > grateful. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
