All, Thanks for all the help! Hauke reminded me to use <\ to generate increasing length lists, as well as a more concise way to remove all blanks: rab2 =: -.&'
Xash showed me the power of @, and how to avoid integer overflow to floating point : ]m=:<\ *: >: i.15 (sep @ ". @ (,&'x') @ rab @ ": @ ,)each m More concise, but this loses the extended integers: <@( [: ". @ ,. @ ; <@":"0)\ *: >: i. 15 Bob showed how to eliminate the character/integer conversions altogether: ([:;10&#.^:_1&.>)&.><\*:>: i.15 │1│1 4│1 4 9│1 4 9 1 6│1 4 9 1 6 2 5│1 4 9 1 6 2 5 3 6│1 4 9 1 6 2 5 3 6 4 9│1 4 9 1 6 2 5 3 6 4 9 6 4│1 4 9 1 6 2 5 3 6 4 9 6 4 8 1│1 4 9 1 6 2 5 3 6 4 9 6 4 8 1 1 0 0│1 4 9 1 6 2 5 3 6 4 9 6 4 8 1 1 0 0 1 2 1│1 4 9 1 6 2 5 3 6 4 9 6 4 8 1 1 0 0 1 2 1 1 4... Great lessons! Thanks all of you so much! Skip Skip Cave Cave Consulting LLC On Fri, Aug 21, 2020 at 12:46 PM Skip Cave <[email protected]> wrote: > Definitions: > ea =: each > > rab =: ]#~[:-.' '=] NB. Remove all blanks. > > sep =:10 #.^:_1 ] NB. separate digits. > > > NB. Generate increasing lengths of integer squares & store in m: > > ]m=.1{.ea n,\ ea {sq=.*:n=.>:i.15 > > │1│1 4│1 4 9│1 4 9 16│1 4 9 16 25│1 4 9 16 25 36│1 4 9 16 25 36 49│1 4 9 > 16 25 36 49 64│1 4 9 16 25 36 49 64 81│1 4 9 16 25 36 49 64 81 100│1 4 9 16 > 25 36 49 64 81 100 121│1 4 9 16 25 36 49 64 81 100 121 144│1 4 9 16 25 36 > 49 64 81 100 121 144 169│1 4 9 16... > > datatype each m > > > │integer│integer│integer│integer│integer│integer│integer│integer│integer│integer│integer│integer│integer│integer│integer│ > > > NB. Convert each box to characters, remove blanks, convert back to > integers, separate the digits, store in p, & display: > > ]p=.sep ea ". ea rab ea":ea ,ea m > > │1│1 4│1 4 9│1 4 9 1 6│1 4 9 1 6 2 5│1 4 9 1 6 2 5 3 6│1 4 9 1 6 2 5 3 6 4 > 9│1 4 9 1 6 2 5 3 6 4 9 6 4│1 4 9 1 6 2 5 3 6 4 9 6 4 8 1│1 4 9 1 6 2 5 3 6 > 4 9 6 4 8 1 1 0 0│1 4 9 1 6 2 5 3 6 4 9 6 4 8.11328 0 0 0 0 0 0 0│1 4 9 1 6 > 2 5 3 6 4 9 6 4 8.11328 0 0 0... > > > NB. UhOh! there are floating-point numbers in p! should all be integers! > > datatype each p > > > │integer│integer│integer│integer│integer│integer│integer│integer│integer│integer│floating│floating│floating│floating│floating│ > > > NB. What is with the floating point numbers 8.11328 in p? They should be > all integers! > > > Also, is there a better way to generate increasing length sets of a > vector? > > JVERSION > > Engine: j902/j64avx2/windows > > Beta-e: commercial/2020-08-14T11:56:28 > > Library: 9.02.05 > > Qt IDE: 1.8.7/5.12.7(5.12.7) > > Platform: Win 64 > > Installer: J902 install > > InstallPath: c:/users/skip/j902 > > Contact: www.jsoftware.com > > > Skip Cave > Cave Consulting LLC > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
