How do you define "elegant"? I know you do not like & but I like it, and maybe this will give you a chance to dig into the code to see how it works (when you translate out the & parts):
clean=: rplc&(,(;' '"0)&":&>-1+i.9)"1 L:0 clean (1+i.20) -table 1+i.10 ┌──┬─────────────────────────────┐ │- │ 1 2 3 4 5 6 7 8 9 10│ ├──┼─────────────────────────────┤ │ 1│ 0 │ │ 2│ 1 0 │ │ 3│ 2 1 0 │ │ 4│ 3 2 1 0 │ │ 5│ 4 3 2 1 0 │ │ 6│ 5 4 3 2 1 0 │ │ 7│ 6 5 4 3 2 1 0 │ │ 8│ 7 6 5 4 3 2 1 0 │ │ 9│ 8 7 6 5 4 3 2 1 0 │ │10│ 9 8 7 6 5 4 3 2 1 0│ │11│10 9 8 7 6 5 4 3 2 1│ │12│11 10 9 8 7 6 5 4 3 2│ │13│12 11 10 9 8 7 6 5 4 3│ │14│13 12 11 10 9 8 7 6 5 4│ │15│14 13 12 11 10 9 8 7 6 5│ │16│15 14 13 12 11 10 9 8 7 6│ │17│16 15 14 13 12 11 10 9 8 7│ │18│17 16 15 14 13 12 11 10 9 8│ │19│18 17 16 15 14 13 12 11 10 9│ │20│19 18 17 16 15 14 13 12 11 10│ └──┴─────────────────────────────┘ Thanks, -- Raul On Sun, Jan 4, 2015 at 11:34 AM, Linda Alvord <[email protected]> wrote: > In the beginning of J TECH Grade 3, I am summarizing the facts that > students > should have learned in Grade 2 at the outset. > > > > Addition and Subtraction are a pair of inverse functions. Students learned > addition facts for numbers 0 to 10. The sums range from 0 to 20. > > > > Thus the inverse must include the numbers from 0 - 20 divided by 1 to 10. > You can't divide by 0. Students haven't met negative numbers. > > > > So here's the charts I want. Do you know any ways I could do this more > simply or elegantly? > > > > A=:":((i.20)>:/i.10)*(i.20)-/i.10 > > B=:(|._3*i.10),10$0 > > C=:B|.!.' '"0 1 A > > D=:(-B)|.!.' '"0 1 C > > TOP=: (<' - '),<}.,' ' ,"1":,.>:i.10 > > BOT=:(<,.>:i.20),<D > > ]PLUS=:+table i.11 > > ---T--------------------------------┐ > │+ │ 0 1 2 3 4 5 6 7 8 9 10│ > +--+--------------------------------+ > │ 0│ 0 1 2 3 4 5 6 7 8 9 10│ > │ 1│ 1 2 3 4 5 6 7 8 9 10 11│ > │ 2│ 2 3 4 5 6 7 8 9 10 11 12│ > │ 3│ 3 4 5 6 7 8 9 10 11 12 13│ > │ 4│ 4 5 6 7 8 9 10 11 12 13 14│ > │ 5│ 5 6 7 8 9 10 11 12 13 14 15│ > │ 6│ 6 7 8 9 10 11 12 13 14 15 16│ > │ 7│ 7 8 9 10 11 12 13 14 15 16 17│ > │ 8│ 8 9 10 11 12 13 14 15 16 17 18│ > │ 9│ 9 10 11 12 13 14 15 16 17 18 19│ > │10│10 11 12 13 14 15 16 17 18 19 20│ > L--+--------------------------------- > > ]MINUS=:TOP,:BOT > > ----T-----------------------------┐ > │ - │ 1 2 3 4 5 6 7 8 9 10│ > +---+-----------------------------+ > │ 1 │ 0 │ > │ 2 │ 1 0 │ > │ 3 │ 2 1 0 │ > │ 4 │ 3 2 1 0 │ > │ 5 │ 4 3 2 1 0 │ > │ 6 │ 5 4 3 2 1 0 │ > │ 7 │ 6 5 4 3 2 1 0 │ > │ 8 │ 7 6 5 4 3 2 1 0 │ > │ 9 │ 8 7 6 5 4 3 2 1 0 │ > │10 │ 9 8 7 6 5 4 3 2 1 0│ > │11 │10 9 8 7 6 5 4 3 2 1│ > │12 │11 10 9 8 7 6 5 4 3 2│ > │13 │12 11 10 9 8 7 6 5 4 3│ > │14 │13 12 11 10 9 8 7 6 5 4│ > │15 │14 13 12 11 10 9 8 7 6 5│ > │16 │15 14 13 12 11 10 9 8 7 6│ > │17 │16 15 14 13 12 11 10 9 8 7│ > │18 │17 16 15 14 13 12 11 10 9 8│ > │19 │18 17 16 15 14 13 12 11 10 9│ > │20 │19 18 17 16 15 14 13 12 11 10│ > L---+------------------------------ > > > > Thanks in advance. > > > > Linda > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
