Re: [Jprogramming] computed shape

2020-08-21 Thread 'Rob Hodgkinson' via Programming
Indeed a good point Julian that is also a handy idiom for “pairwise” in J. Note the q version also allows the null (0N) to be placed anywhere in the shape vector, so if you knew the list had 3 groups, but weren’t sure how many items in the group then you could also do this: q)3 0N#args

Re: [Jprogramming] Strange output.

2020-08-21 Thread Skip Cave
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 @ ": @

Re: [Jprogramming] Strange output.

2020-08-21 Thread 'robert therriault' via Programming
Using Hauke's creation of m=: <\ *: >:i.9 NB. I used 9 instead of 15 for display purposes on the email I would not bother using all the character conversions, but would stay with integers and use 10&#.^:_1 to take the digits apart. Some boxing and a Raze (;) is required to avoid padding.

Re: [Jprogramming] Strange output.

2020-08-21 Thread Hauke Rehr
I’d want to get rid of one @ in the chain at the expense of introducing rank <@( [: "."0 @ ; <@":"0)\ *: >: i. 15 Am 21.08.20 um 20:22 schrieb x...@xn--wxa.land: … and depending on what you want, there might be a better approach: parse the numbers, raze the strings, itemize the characters, and

Re: [Jprogramming] Strange output.

2020-08-21 Thread xash
… and depending on what you want, there might be a better approach: parse the numbers, raze the strings, itemize the characters, and interpret each as a digit. <@( [: ". @ ,. @ ; <@":"0)\ *: >: i. 15 On Fri, 21 Aug 2020 12:46:24 -0500 Skip Cave wrote: > Definitions: > ea =: each > > rab =: ]#

Re: [Jprogramming] Strange output.

2020-08-21 Thread Hauke Rehr
… and maybe you want to use rab2 =: -.&' ' Am 21.08.20 um 20:02 schrieb x...@xn--wxa.land: ]m=:<\ *: >: i.15 (sep @ ". @ (,&'x') @ rab @ ": @ ,)each m Appends a 'x' after each number string, so it will get interpreted as an extended number. Otherwise big numbers get converted to floats, e.g.

Re: [Jprogramming] Strange output.

2020-08-21 Thread xash
]m=:<\ *: >: i.15 (sep @ ". @ (,&'x') @ rab @ ": @ ,)each m Appends a 'x' after each number string, so it will get interpreted as an extended number. Otherwise big numbers get converted to floats, e.g. 149162536496481100121 -> 1.49163e20. On Fri, 21 Aug 2020 12:46:24 -0500 Skip Cave wrote: >

Re: [Jprogramming] Strange output.

2020-08-21 Thread Hauke Rehr
I’d start with something like <\ *: >:i.15 Am 21.08.20 um 19:46 schrieb Skip Cave: Also, is there a better way to generate increasing length sets of a vector? -- -- mail written using NEO neo-layout.org -

[Jprogramming] Strange output.

2020-08-21 Thread Skip Cave
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│

Re: [Jprogramming] computed shape

2020-08-21 Thread Julian Fondren
On 2020-08-21 10:55, 'Rob Hodgkinson' via Programming wrote: ... q)0N 2#args /Comment: q uses the NULL value (0N) to say “I know the list is in pairs, so work out the rows" (hence here 3 x 2) "Code" 33 "Name" "Iverson" "Age” 34 The equivalent mechanism in APL or J is along these li

Re: [Jprogramming] computed shape

2020-08-21 Thread Joseph Novakovich
Small correction: '[ -: $@($,)' On 8/21/20, Joseph Novakovich wrote: > I would expect '[ -: $@$' to hold, which this would break. > > Cheers > > On 8/21/20, 'Rob Hodgkinson' via Programming > wrote: >> Henry I am just clarifying here but not advocating one way or the other >> …. >> >> This featu

Re: [Jprogramming] computed shape

2020-08-21 Thread Joseph Novakovich
I would expect '[ -: $@$' to hold, which this would break. Cheers On 8/21/20, 'Rob Hodgkinson' via Programming wrote: > Henry I am just clarifying here but not advocating one way or the other …. > > This feature is part of q (or k) and is implemented as an extension of the > reshape function (wh

Re: [Jprogramming] computed shape

2020-08-21 Thread 'Rob Hodgkinson' via Programming
Henry I am just clarifying here but not advocating one way or the other …. This feature is part of q (or k) and is implemented as an extension of the reshape function (which is # in q). Here is a q sample, q)args:("Code";33;"Name";"Iverson";"Age";34) /Comment: Here my list migh

Re: [Jprogramming] computed shape

2020-08-21 Thread Hauke Rehr
Say u is your current processing and v tells what axes are meant to look like in the result. Then I think (v@$ $ u) data does the trick already. Looks like a simple conjunction to me. If otoh you don’t know v, J won’t either. Am 21.08.20 um 02:40 schrieb Henry Rich: I don't think it fits into th

Re: [Jprogramming] Code smells in J

2020-08-21 Thread 'Michael Day' via Programming
Any clue as to the input to summary,  or what you're summarising? Sorry if it's obvious! Note these (display ?) errors: pol =. _1 [space] x: ... hp =. x [space] :: ] ... Cheers, Mike On 21/08/2020 15:41, 'Bo Jacoby' via Programming wrote: tomb=.(^/i.@>:)~ NB. tombola lottery powers his

Re: [Jprogramming] Code smells in J

2020-08-21 Thread 'Bo Jacoby' via Programming
tomb=.(^/i.@>:)~ NB. tombola lottery powers hist=.({."1~>:)~(*[:^/~i.@#@,)NB. histogram powers s=.(*#)@ (}.%{.) @ (+/) NB. summation f1=.$~2# # NB. n*n matrix f2=.>:@i.@#, }: NB. insert S0, remove Sn f3=.*_1^i.@# NB. change sign f4=.|:|.!.0"01~-@i.@# NB. shift zeroes in m=.|:@f4@(f3"1@f2@|:@f1) N

Re: [Jprogramming] Code smells in J

2020-08-21 Thread 'Bo Jacoby' via Programming
tomb=.(^/i.@>:)~ NB. tombola lottery powershist=.({."1~>:)~(*[:^/~i.@#@,)NB. histogram powerss=.(*#)@ (}.%{.) @ (+/) NB. summationf1=.$~2# # NB. n*n matrixf2=.>:@i.@#, }: NB. insert S0, remove Snf3=.*_1^i.@# NB. change signf4=.|:|.!.0"01~-@i.@# NB. shift zeroes inm=.|:@f4@(f3"1@f2@|:@f1) NB. m

Re: [Jprogramming] Code smells in J

2020-08-21 Thread 'Bo Jacoby' via Programming
Thank you! I was trying to accomplish this tomb=.(^/i.@>:)~ NB. tombola lottery powershist=.({."1~>:)~(*[:^/~i.@#@,)NB. histogram powerss=.(*#)@ (}.%{.) @ (+/) NB. summationf1=.$~2# # NB. n*n matrixf2=.>:@i.@#, }: NB. indsæt S0, fjern Snf3=.*_1^i.@# NB. change signf4=.|:|.!.0"01~-@i.@# NB. shif

Re: [Jprogramming] Code smells in J

2020-08-21 Thread ethiejiesa via Programming
Bo Jacoby wrote: > How to de-smell this: > 3([* i.@#@,@[ ^/ i.@>:@])~ 0 0 1 1 1 3 (]* ((^/&i. >:)~ #)) 0 0 1 1 1 Maybe? That comes from just a little mechanical algebra: > 3([* i.@#@,@[ ^/ i.@>:@])~ 0 0 1 1 1 First notice the repeated (i.) on either argument of (^/). There is a general

Re: [Jprogramming] Code smells in J

2020-08-21 Thread R.E. Boss
3(({."1 ~>:)~ (* [:^/~ i.@#@,)) 0 0 1 1 1 R.E. Boss -Original Message- From: Programming On Behalf Of 'Bo Jacoby' via Programming Sent: vrijdag 21 augustus 2020 12:49 To: programm...@jsoftware.com Subject: Re: [Jprogramming] Code smells in J How to de-smell this: 3([* i.@#@,@[ ^/ i

Re: [Jprogramming] Code smells in J

2020-08-21 Thread 'Bo Jacoby' via Programming
How to de-smell this: 3([* i.@#@,@[ ^/ i.@>:@])~ 0 0 1 1 1 ? I tried but in vain. Thank you! BoDen fredag den 21. august 2020 08.18.16 CEST skrev Bo Jacoby : How to remove the smell (the "[" and the "]") from    3(i.@>:@[ ^/~ ])2 3 4 ? Thanks!  Bo. Den fredag den 21. august

Re: [Jprogramming] Code smells in J

2020-08-21 Thread 'Jon Hough' via Programming
Regarding my own J code. Code smells are 1. superfluous rank assignments on verbs. Shows that I don't know the verb ranks well enough. 2. Over reliance on ,/ and , to get out of a "oh no my result has the wrong shape" problem. Better to figure out why it has the wrong shape. 3. Overuse of pa