Re: [Jprogramming] Replace one item of a list

2014-09-09 Thread Roger Hui
Linda Alvord > > wrote: > > > > > The verb is amend and the main issue is that you must separate 100 > and 2 > > > or > > > they become the list 100 2 > > > > > > 100 (2)} A=.i.5 > > > 0 1 100 3 4 > > > > > >

Re: [Jprogramming] Replace one item of a list

2014-09-09 Thread Roger Hui
I don't believe the messages you cited explained it. J syntax consists of word formation as defined by ;: and parsing rules as defined by Section IIE of the dictionary. How is amend-in-place not permitted by either part? On Tue, Sep 9, 2014 at 8:56 AM, Dan Bron wrote: > Ian wrote: > > Then

Re: [Jprogramming] Replace one item of a list

2014-09-09 Thread Roger Hui
ascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > We understand the parsing rules as: > > a =: a > > to cause =: to have no awareness that 'a' was a part of the far off > expression to the right. > > > - Original Message -

Re: [Jprogramming] Extend/reduce matrix dimensions

2014-09-11 Thread Roger Hui
Fractional axes specs are an abomination. Don't bother trying to model it. ,: and ,:"r are far superior. On Thu, Sep 11, 2014 at 7:00 AM, Dan Bron wrote: > Ben Gorte wrote: > > I use an adverb called ins that behaves like } , except that it inserts > :) > > In the argument to the adverb, does

Re: [Jprogramming] Question on rank conjunction's behavior regarding "unexpected" vector transposition

2014-09-12 Thread Roger Hui
> For example, if an array has shape 2 3 4, then Matlab treats this as 4 > matrices, each 2x3, while J treats it as 2 matrices, each 3x4. This leads me to the conjecture that Matlab stores arrays in column-major order, like FORTRAN. J and APL stores arrays in row-major order. On Fri, Sep 12,

Re: [Jprogramming] Literal to Integer / Numeric

2014-09-14 Thread Roger Hui
". '5.32' 5.32 12 + ". '5.32' 17.32 The dyad ". is specifically for numeric conversion and is more efficient and handier: _999 ". '5.32' 5.32 _999 ". '34skidoo' _999 On Sun, Sep 14, 2014 at 6:01 AM, Jon Hough wrote: > This is possibly a very simple question with a very simple an

Re: [Jprogramming] orthogonalizing a matrix

2014-09-16 Thread Roger Hui
It should be possible to write a recursive matrix-oriented orthogonalization. See http://www.jsoftware.com/jwiki/Essays/QR_Decomposition . On Mon, Sep 15, 2014 at 11:56 PM, 'Bo Jacoby' via Programming < programm...@jsoftware.com> wrote: > I managed to ortogonalize a 10 10 - matrix like this: > >

Re: [Jprogramming] Repeated rolling dice

2014-09-25 Thread Roger Hui
​Compared to the other solutions posted so far, I believe it is more straightforward to do a long sequence of dice rolls and then split it up according to your specified criteria. The split point are where the _previous_ roll is _not_ a 6. Thus: ​ x=: 1+1e4 ?@$ 6 NB. long sequence of dice ro

Re: [Jprogramming] Repeated rolling dice

2014-09-25 Thread Roger Hui
> - Original Message - > From: Devon McCormick > To: J-programming forum > Cc: > Sent: Thursday, September 25, 2014 1:40 PM > Subject: Re: [Jprogramming] Repeated rolling dice > > This looks like a good addition to my growing set of "array-thinking" > examples

Re: [Jprogramming] Repeated rolling dice

2014-09-25 Thread Roger Hui
t; examples. > > On Thu, Sep 25, 2014 at 12:32 PM, Roger Hui > wrote: > > > ​Compared to the other solutions posted so far, I believe it is more > > straightforward to do a long sequence of dice rolls and then split it up > > according to your specified criteria. The spli

Re: [Jprogramming] An easy one

2014-10-17 Thread Roger Hui
2 */@(^|.)\ p: i.6x 72 30375 1313046875 38532504363714053 61870237399093306018139447 On Fri, Oct 17, 2014 at 4:30 PM, Kip Murray wrote: > 72 30375 1313046875 > > The first of these numbers is (2^3) * (3^2) , the second is (3^5) * (5^3), > and the third is (5^7) * (7^5) . You see the pattern

Re: [Jprogramming] An easy Euler Project one (485)

2014-10-21 Thread Roger Hui
> 4) So is there a better d verb out there - capable of running efficiently > on a vector argument? (Or a p: or q: extension as per 0 above?) Having thought about it for 10 seconds, I would say that for a vector argument indicating a range of numbers (e.g. from 0 to 1-n), a sieve-like method sho

Re: [Jprogramming] An easy Euler Project one (485)

2014-10-21 Thread Roger Hui
__ q: 30 2 3 5 1 1 1 The number of divisors are the possible vectors of exponents, which in this case are {0 1;0 1;0 1. For each prime, if the maximum exponent is e, then the possible exponents for that prime is 0 1 2 3 ... e-1,e, i.e. the number of possible exponents is 1+e. That's why I sug

Re: [Jprogramming] An easy Euler Project one (485)

2014-10-21 Thread Roger Hui
rashing for memory. > > Pascal Jasmin's alternative for d is attractive. In tacit form >*/@:>:@:(#/.~)@:-.&0"1@:q: > is quicker and leaner than >*/@:(>:@{:)"2@(__&q:) > for >: i. 100 though slower albeit still leaner > for >: i. 1

Re: [Jprogramming] count of consecutive 1s

2014-10-22 Thread Roger Hui
You can probably do better than the following, but it'd be useful as a result checker: ] x=: 0<20 ?@$ 3 0 1 1 1 0 1 1 1 0 1 1 0 0 1 0 0 0 0 1 1 }. ; +/\&.> <;.1 ] 0,x 0 1 2 3 0 1 2 3 0 1 2 0 0 1 0 0 0 0 1 2 On Wed, Oct 22, 2014 at 10:10 AM, Joe Bogner wrote: > This is probably easy but

Re: [Jprogramming] count of consecutive 1s

2014-10-22 Thread Roger Hui
x 0 1 1 1 0 1 1 1 0 1 1 0 0 1 0 0 0 0 1 1 s->./\(-.x)*s=.+/\x 0 1 2 3 0 1 2 3 0 1 2 0 0 1 0 0 0 0 1 2 On Wed, Oct 22, 2014 at 10:21 AM, Roger Hui wrote: > You can probably do better than the following, but it'd be useful as a > result checker: > >] x=: 0<20 ?@

Re: [Jprogramming] n-wise reduction

2014-10-27 Thread Roger Hui
The dyad n f\x provides infix of size n. Reduction is not automatically provided so if you want reduction you have to specify it explicitly: 2 +/\ 1+i.10 3 5 7 9 11 13 15 17 19 Since reduction is not built in you can apply other functions, such as < (box): 2 <\ 1+i.10 ┌───┬───┬───┬───┬───

Re: [Jprogramming] shorter way to prefix lines altenatively?

2014-11-03 Thread Roger Hui
; ((('A:';'B:') $~ #) ,&.> ]) <;.2 t On Mon, Nov 3, 2014 at 3:50 AM, June Kim (김창준) wrote: > Hello > > > I am looking for a shorter and more elegant way to do the following given a > string t: > >t=. 0 :0 > > abc > > defg > > hijkl > > erws > > opqow > > > sdfsdf > > dofi > > ) > >,&:>/

Re: [Jprogramming] Boxing columns

2014-11-19 Thread Roger Hui
('';1) <;.1 i.3 3 ┌─┬─┬─┐ │0│1│2│ │3│4│5│ │6│7│8│ └─┴─┴─┘ On Wed, Nov 19, 2014 at 2:05 PM, Henry Rich wrote: >boxcols i. 3 3 > +-+-+-+ > |0|1|2| > |3|4|5| > |6|7|8| > +-+-+-+ > > Can you write boxcols? > > Can you write it tacitly without using a hook, fork, compose, or appose? > > Henry

Re: [Jprogramming] Boxing columns

2014-11-19 Thread Roger Hui
The inverse of this "block matrices cut" is also interesting. On Wed, Nov 19, 2014 at 2:27 PM, Roger Hui wrote: >('';1) <;.1 i.3 3 > ┌─┬─┬─┐ > │0│1│2│ > │3│4│5│ > │6│7│8│ > └─┴─┴─┘ > > > On Wed, Nov 19, 2014 at 2:05 PM, Henry Rich wrote:

Re: [Jprogramming] Boxing columns

2014-11-19 Thread Roger Hui
───┤ │15 16│17 18 19│ └─┴┘ On Wed, Nov 19, 2014 at 2:40 PM, Henry Rich wrote: > Is the inverse implemented using ^:_1 ? I couldn't find it. > > I come up with ,.&:>/ as an inverse for ('';1)&(<;.1) . > > Henry Rich > > > On 11/19/2014 5:28 P

Re: [Jprogramming] Boxing columns

2014-11-19 Thread Roger Hui
What reasoning do you mean please? In mathematics and in computer science block matrices can be manipulated to advantage. See for example: http://www.jsoftware.com/jwiki/Essays/Triangular%20Matrix%20Inverse http://www.jsoftware.com/jwiki/Essays/Choleski%20Decomposition http://www.jsoftware.com/jw

Re: [Jprogramming] What's wrong with assigment?

2014-11-20 Thread Roger Hui
> This violates universality. Universality is not necessarily a good principle for language design. 1.2 3.4 $ 5.6 |domain error | 1.2 3.4$5.6 'abc' $ 3 4 5 |domain error | 'abc'$3 4 5 On Wed, Nov 19, 2014 at 11:46 PM, Sergey Kamenev wrote: > 20.11.2014 09:05, Jan-Pieter J

Re: [Jprogramming] Correct behavior of "e." ?

2014-11-20 Thread Roger Hui
Both expressions give the correct answer. The right argument of membership determines the target of the items to be sought, just like the left argument of index-of determines the targets. In my opinion, the APL\360 team made a mistake by making x∊y the same as x∊,y. We are struggling with the co

Re: [Jprogramming] Correct behavior of "e." ?

2014-11-20 Thread Roger Hui
not be used because ⍺∊⍵ ←→ ⍺∊,⍵. At least, it can not be used if we want to be compatible with old code. (≢ is tally, ⍨ is commute.) On Thu, Nov 20, 2014 at 10:31 AM, Devon McCormick wrote: > I see, so > >0 1 e. i.2 2 > 1 > > > On Thu, Nov 20, 2014 at 1:27 PM, Roger Hui

Re: [Jprogramming] Complex puzzle WAS: Better way to locate coomplex or real numbers in an array

2014-11-29 Thread Roger Hui
See http://www.jsoftware.com/jwiki/Essays/Tolerant_Comparison#Comparisons_with_0 On Sat, Nov 29, 2014 at 10:22 PM, robert therriault wrote: > It looks to me as if the fact that 0 is being compared is significant. > >0 (~:!.0) 1e_45 > 1 >0 (~:) 1e_45 > 1 > > I would expect the intolerant

Re: [Jprogramming] why 0 0&$ instead of 0&$ ?

2014-12-09 Thread Roger Hui
0&$ generates an empty line as output; 0 0& generates no discernable output. On Tue, Dec 9, 2014 at 2:51 AM, Michal Wallace wrote: > The standard verb 'echo' is defined as ( 0 0&$@(1!:2&2) ) > > The ( 0 0&$ ) obviously throws away the result so it's not echoed in the > REPL. > > But why ( 0 0 )

Re: [Jprogramming] "Such that" syntax in J

2014-12-26 Thread Roger Hui
f x where x is an array of all values of interest. For (countably) infinite sets you have to express x in terms of i._ . For example, to express the Euler product formula for the Riemann zeta function, +/(1+i._)^-s ←→ */%1-(p:i._)^-s On Fri, Dec 26, 2014 at 8:04 AM, Jon Hough wrote: > >

Re: [Jprogramming] "Such that" syntax in J

2014-12-26 Thread Roger Hui
←→ are metasymbols, commonly used in mathematics to denote equivalence. On Fri, Dec 26, 2014 at 8:20 AM, Jon Hough wrote: > > Thanks for replying. > > I'm confused about two things. > > (1) I'm worried I haven't explained myself well. > I mean I want to find all x given g(x) is true for some fu

Re: [Jprogramming] "Such that" syntax in J

2014-12-26 Thread Roger Hui
nal Message- > > From: programming-boun...@forums.jsoftware.com [mailto:programming- > > boun...@forums.jsoftware.com] On Behalf Of Roger Hui > > Sent: vrijdag 26 december 2014 17:28 > > To: Programming forum > > Subject: Re: [Jprogramming] "Such that" syntax in J

Re: [Jprogramming] Forward fill w/o looping

2015-01-05 Thread Roger Hui
t=: '';'Hi';'';'';'Ho';'';'hee';'';'';'haw';'';'';'Yo';'' fillEmptyFwd t ┌┬──┬──┬──┬──┬──┬───┬───┬───┬───┬───┬───┬──┬──┐ ││Hi│Hi│Hi│Ho│Ho│hee│hee│hee│haw│haw│haw│Yo│Yo│ └┴──┴──┴──┴──┴──┴───┴───┴───┴───┴───┴───┴──┴──┘ (({.t),b#t) {~ +/\b=: *#&>t ┌┬──┬──┬──┬──┬──┬───┬───┬───┬───┬───┬───┬──┬

Re: [Jprogramming] Forward fill w/o looping

2015-01-05 Thread Roger Hui
.com> wrote: > a verbed variation of Roger's > > (] (({.@:[ , #~) {~ +/\@:] ) [: * #&>) > '';'Hi';'';'';'Ho';'';'hee';'';'';'haw';'';'';'Yo&#x

Re: [Jprogramming] FWD: Help me understand line of code:

2015-01-06 Thread Roger Hui
93 What are the indices of paths with the maximal sum? I. s=>./s 12925 So there is only one such path. On Tue, Jan 6, 2015 at 8:24 AM, oventarb oventarb wrote: > ​​ >> ./ +/"1 (+/\"1 ]0,.15

Re: [Jprogramming] nth digit of pi

2015-01-06 Thread Roger Hui
Answering the letter if not the spirit of your question: f=: 3 : '10|<.@o. 10x^y' f"0 i.5 20 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0 2 8 8 4 1 9 7 1 6 9 3 9 9 3 7 5 1 0 5 8 2 0 9 7 4 9 4 4 5 9 2 3 0 7 8 1 6 4 0 6 2 8 6 2 0 8 9 9 8 6 2 8 0 3 4 8 2 5 3 4 2 1 1 7 0 6 7

Re: [Jprogramming] nth digit of pi

2015-01-06 Thread Roger Hui
125159482533123957 1}.":<.@o. 10^100x 1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 Alternatively, enter f 1e4 and wait. :-) On Tue, Jan 6, 2015 at 1:04 PM, 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > to be more specific, a function that gets the 10000th digit of pi? >

Re: [Jprogramming] Dear Roger Hui!

2015-01-10 Thread Roger Hui
b oventarb wrote: > > Dear Roger Hui! > I solved problem 67 using Java. > What does this code mean: > > {. (+ 0: ,~ 2: >./\ ])/ m > -- > For information about J forums se

Re: [Jprogramming] J Equivalent of Python Struct.Pack/Unpack

2015-01-21 Thread Roger Hui
Have you looked at 3!:4 and 3!:5 ? On Wed, Jan 21, 2015 at 7:56 PM, Jon Hough wrote: > Basically, I am hoping to pack data in J and be able to unpack in Python, > or any other language (and vice versa). > Thats why I am a little concerned about these 5 extra words added. > > --- Original Messa

Re: [Jprogramming] Recalling and editing lines in jqt

2015-01-25 Thread Roger Hui
I use both (Dyalog and J) regularly. When you are used to one way the other way can seem annoying, counter-intuitive, clumsy, you name it, ... because your fingers seem to retain a memory of how things work. But it doesn't mean the other way is wrong. One difference is Dyalog treats the session

Re: [Jprogramming] Convertion of text from lower case to upper case

2015-02-22 Thread Roger Hui
Not the usual place to look, but there is published code for it: http://keiapl.org/anec/#nvv On Sun, Feb 22, 2015 at 5:52 AM, Chernin, Nadav wrote: > Hi, > I just started to learn J and I try to resolve some problems > One of them is to convert text from lower case to upper case > Please help me

Re: [Jprogramming] Jd version 2.2

2015-03-08 Thread Roger Hui
Eric's first the announcement was in error (wrong e-mail address). He sent his message _after_ his announcement. I will now send a message to the database forum to show that you do get the database messages. On Sun, Mar 8, 2015 at 2:25 PM, greg heil wrote: > >Yes that is when i made sure to d

Re: [Jprogramming] partitioned sort

2015-04-15 Thread Roger Hui
psort is due to Morten Kromberg, I believe. If the right argument is numeric, there are alternatives to do partition sort without boxing but using grade or sort just once. psort1=: ] /: +/\@[ ,"_1 ]NB. y /: (+/\x),"_1 y psort2=: ] /: ] + +/\@[ * +:@(>./)@:|@] NB. y /: y + (+/\x)

Re: [Jprogramming] Permutations with repeats (combinations?)

2015-04-24 Thread Roger Hui
The "secret" is to avoid generating duplicates which are then removed. Partition the argument into a collection of like elements: :d=.y-x z=. (d$ ,&.>/\. >:&.> z end. ; z ) (#s) comb (#s)+{:$m 0 1 0 2 0 3 1 2 1 3 2 3 From these column indices generate the z: 0 1 2 2 0 1 2 2 1 0 0

Re: [Jprogramming] Permutations with repeats (combinations?)

2015-04-24 Thread Roger Hui
V. good. On Fri, Apr 24, 2015 at 10:46 PM, Raul Miller wrote: > On Fri, Apr 24, 2015 at 7:03 PM, Roger Hui > wrote: > > The details of implementing this algorithm are left as an exercise for > the > > reader. :-) > > Do I qualify as a reader? > > comb=:

Re: [Jprogramming] Permutations with repeats (combinations?)

2015-04-25 Thread Roger Hui
The peermm function can be made faster by doing the actual permutations of those cells of wrote: > On Fri, Apr 24, 2015 at 7:03 PM, Roger Hui > wrote: > > The details of implementing this algorithm are left as an exercise for > the > > reader. :-) > > Do I qualify as

Re: [Jprogramming] Puzzle: nontransitive rank

2015-05-07 Thread Roger Hui
Hint: the "combining rank" is always positive, so that, for example: +"_1 b. 0 _ _ _ (And not _1 _1 _1 as you might expect.) On Thu, May 7, 2015 at 1:19 PM, 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > cool puzzle that seems unsolvable given > http://www.jsoftware

Re: [Jprogramming] Test if anagram in one line code

2015-06-08 Thread Roger Hui
Strings x and y are anagrams if x -:&(/:~)&(-.&'. ')&tolower y . That is, compare them after reducing them to a standard form, by (converting to lower case, then deleting spaces and dots (and whatever), then sorting them). On Mon, Jun 8, 2015 at 6:27 AM, Gian Medri wrote: > Is there a shor

Re: [Jprogramming] ^.@!

2015-06-10 Thread Roger Hui
Can the argument be other than positive integers? On Wed, Jun 10, 2015 at 6:22 AM, Raul Miller wrote: > Does anyone have an implementation of ^.@! which will work for > moderately large values (like 1000)? > > Thanks, > > -- > Raul > --

Re: [Jprogramming] ^.@!

2015-06-10 Thread Roger Hui
. > > Motivation is this rosettacode task: > http://rosettacode.org/wiki/Calculate_P-Value > > Thanks, > > -- > Raul > > On Wed, Jun 10, 2015 at 9:25 AM, Roger Hui > wrote: > > Can the argument be other than positive integers? > > > > On Wed,

Re: [Jprogramming] J iOS and iOS 8.4

2015-07-10 Thread Roger Hui
> PS. Time on the iPhone 6 to invert a 500x500 matrix is only 0.55 sec! If you can do one for a 50x50 matrix the result can be added to http://www.jsoftware.com/jwiki/Essays/JKT_Benchmark On Fri, Jul 10, 2015 at 1:22 PM, J. Patrick Harrington wrote: > I've just upgraded my old iPhone 4S to a n

Re: [Jprogramming] J iOS and iOS 8.4

2015-07-10 Thread Roger Hui
> So it looks like this is not meaningful for such a small matrix with current machines. Reminds me of the following story from Chinese history. A king from a minor kingdom was visiting a rich man, reputed to be very rich indeed. So the king wore a special coat made with the finest fabric (the e

Re: [Jprogramming] row puzzle

2015-07-18 Thread Roger Hui
row=: ,&(,:^:(1=#@$)) 1 2 row 3 4 1 2 3 4 1 2 row 3 4 row 5 6 1 2 3 4 5 6 (1 2 row 3 4) row 5 6 1 2 3 4 5 6 (1 2 row 3 4) row 5 6 row 7 8 1 2 3 4 5 6 7 8 On Sat, Jul 18, 2015 at 5:04 PM, Kip Murray wrote: > Write a verb row so that > > 1 2 row 3 4 > 1 2 > 3 4 > 1 2 r

Re: [Jprogramming] row puzzle

2015-07-18 Thread Roger Hui
And another version: row=: _2&([\)@,&, On Sat, Jul 18, 2015 at 5:17 PM, Henry Rich wrote: > The straightforward version: > >row =. ,&(,:^:(2 > #@$)) > > The shorter but ugly (and slower) version: > >row =. ;@,&:(<@,:"1) > > The beautiful but slowest version: > >row =. ,&.:(<"1)

Re: [Jprogramming] row puzzle

2015-07-18 Thread Roger Hui
This one's the winner. On Sat, Jul 18, 2015 at 5:26 PM, Raul Miller wrote: > row=:_2[\,&, > > would have been more concise? Or is that too silly? > > -- > Raul > > On Sat, Jul 18, 2015 at 8:19 PM, Roger Hui > wrote: > > And another version: > >

Re: [Jprogramming] dot product

2015-07-25 Thread Roger Hui
See also Inner Product -- An Old/New Problem , 2009. On Sat, Jul 25, 2015 at 12:11 PM, Raul Miller wrote: >1 0 1 +/ .* 10 100 1000 > 1010 > > The dot product is arguably a key feature of J. This allows you to > multiply matrices: > >

Re: [Jprogramming] Detecting special products

2015-08-06 Thread Roger Hui
g=: = (^&3 - ])@:(3&(>.@%:)) g */"1 (10^40 60 80x)+/0 1 2 1 1 1 On Thu, Aug 6, 2015 at 11:23 AM, 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > (] = (^&3 - ])@:(1r3 >.@^~ ])) 990 > > > > - Original Message - > From: Kip Murray > To: "programm...@jsoftware.co

Re: [Jprogramming] Detecting special products

2015-08-09 Thread Roger Hui
An advantage of solutions based on taking cube roots, on the expression >.@%: in particular, is working correctly with large integers. For example: g=: = (^&3 - ])@:(3&(>.@%:)) n=: */ 0 1 2 + 11^20x n 304481639541418099575807073027324053193216441247734861355941206 g n 1 g n+1 0 I

Re: [Jprogramming] Detecting special products

2015-08-10 Thread Roger Hui
p. orders the roots by decreasing magnitude, and within that (for roots with equal magnitude) the ordering used by \: . For example: p. p. < 3 1 4 1 5 9 ┌─┬───┐ │1│9 5 4 3 1 1│ └─┴───┘ p. p. <3 1 4 1 5 9 3j4 3j_4 _3j4 _3j_4 ┌─┬───┐ │1│9 5 3j4 3j_4

Re: [Jprogramming] Comparing pairs

2015-08-14 Thread Roger Hui
What you want is "infix": 2 <\ 3 1 4 1 5 9 ┌───┬───┬───┬───┬───┐ │3 1│1 4│4 1│1 5│5 9│ └───┴───┴───┴───┴───┘ 2 -/\ 3 1 4 1 5 9 2 _3 3 _4 _4 On Fri, Aug 14, 2015 at 7:30 AM, Yoel Jacobsen wrote: > Lately, I find myself repeatedly comparing pairs in arrays. > > I usually do something lik

Re: [Jprogramming] Comparing pairs

2015-08-14 Thread Roger Hui
As for efficiency, see the entry for 2 f/\y in http://www.jsoftware.com/help/dictionary/special.htm , with more details in: http://www.jsoftware.com/help/release/infix2.htm http://www.jsoftware.com/help/release/infix2a.htm On Fri, Aug 14, 2015 at 7:40 AM, Roger Hui wrote: > What you want

Re: [Jprogramming] A canon of J violated

2015-10-16 Thread Roger Hui
I agree that there are bugs, but fixing them requires some thinking. As Bill Lam surmised, the problem ultimately can be attributed to tolerant comparison, tolerant equality in particular. The J version I am using in this message is the following: 9!:14 '' j602/2008-03-03/16:45 but the bugs/

Re: [Jprogramming] A canon of J violated

2015-10-17 Thread Roger Hui
r integers and f/.!.0 . Is > there an easy way to tell whether tolerant i.~ encountered items that were > tolerantly equal but not intolerantly equal? > > Henry Rich > > > On 10/16/2015 5:47 PM, Roger Hui wrote: > >> I agree that there are bugs, but fixing them

Re: [Jprogramming] A canon of J violated

2015-10-17 Thread Roger Hui
> As well, +/,selfclassify v should be #v . +/,selfclassify v should be no less than #v . It's really strange for the sum to be less than #v, because that means there are items in v not equal (tolerant or otherwise) to any of the unique items of v . If = is transitive, then +/,selfclassify v is

Re: [Jprogramming] Why is subtraction and division of rational numbers so hard?

2015-11-15 Thread Roger Hui
FYI: Ken Iverson credited Linda with elucidating the mysterious concept of outer product. http://www.jsoftware.com/papers/autobio.htm , Section 5. Linda Alvord said to introduce the matrix as an outer product — an idea that the rest of us thought outrageous, until Linda pointed out that the kids

Re: [Jprogramming] Loop Senility

2015-11-28 Thread Roger Hui
The following article from 1977 may do what you want without looping: http://www.jsoftware.com/papers/Gaboury.htm . (Then again, it may not. :-) On Sat, Nov 28, 2015 at 12:27 PM, John Baker wrote: > A nasty combination of too much recent programming in loopy languages > combined with advancing

Re: [Jprogramming] sorting a table by nth column

2015-12-03 Thread Roger Hui
] x=: ? 10 4 $ 100 33 44 35 49 67 95 56 50 35 70 83 6 26 73 97 11 29 92 71 94 81 13 93 64 47 51 35 98 33 59 52 90 62 0 64 29 14 30 92 98 x /: 1{"1 x 62 0 64 29 81 13 93 64 14 30 92 98 33 44 35 49 47 51 35 98 33 59 52 90 35 70 83 6 26 73 97 11 29 92 71 94 67 95 56 50 On Thu, Dec 3, 201

Re: [Jprogramming] sorting a table by nth column

2015-12-03 Thread Roger Hui
There is an interesting story about the design of the /: primitive: http://keiapl.org/anec/#sort On Thu, Dec 3, 2015 at 12:27 PM, Alex Giannakopoulos < alexg...@blueyonder.co.uk> wrote: > Thanks, that's brilliant. > Funnily enough, I'd read the relevant page on /: and had tried > something ver

Re: [Jprogramming] advent of code day 5

2015-12-05 Thread Roger Hui
> I feel so grown-up, using i.~ If I can only use 16 expressions to show off APL/J, i.~ would be one of them. http://www.jsoftware.com/papers/amuse-bouches.htm#3 On Sat, Dec 5, 2015 at 1:40 PM, Henry Rich wrote: > i =. ];._2 wd 'clippaste' > nice2 =. ([: +./ 3&(=/@:(0 _1&{)\)) *. (1 < >./@(i.@

Re: [Jprogramming] nub and key of inverted table

2015-12-17 Thread Roger Hui
Apply |:@:(i.~&>) to an inverted table and work with that. Quoting from http://www.jsoftware.com/papers/amuse-bouches.htm#3 , ... questions of identity on x can often be answered more efficiently on x⍳x than on x itself. On Thu, Dec 17, 2015 at 7:21 AM, bill lam wrote: > I want an effecient me

Re: [Jprogramming] Appending to columnar tabs

2016-01-05 Thread Roger Hui
a,&.>b On Tue, Jan 5, 2016 at 9:59 AM, Anssi Seppälä wrote: > Dear jfriends, > I am stuck with a simple problem: What is the "correct" method to append > two columnar tables a and b. > > a > +++--+--+++ > |20160104|1003005 |SEY |300511379

Re: [Jprogramming] Roll (?) produces domain error on large input

2016-01-11 Thread Roger Hui
Use extended precision integers. ? !21 |domain error | ?!21 ? !21x 36282724980122910689 On Mon, Jan 11, 2016 at 2:22 AM, Eddie Bracho wrote: > > (? ! 21) > > |domain error > > | ( ?!21) > > > > Is this intended behavior? I'm trying to shuffle an array by providing a > random

Re: [Jprogramming] Roll (?) produces domain error on large input

2016-01-11 Thread Roger Hui
mory > | # ?~!15 > > Skip Cave > Cave Consulting LLC > > > On Mon, Jan 11, 2016 at 9:17 AM, Roger Hui > wrote: > > Use extended precision integers. > > > >? !21 > > |domain error > > | ?!21 > > > >? !21x &

Re: [Jprogramming] Definition: Frame of an argument

2016-01-14 Thread Roger Hui
Empty frame, or more accurately zero frames, if it is said to be for anything, is to allow edge cases, the case where the frame contains a 0, to work without a lot of exceptions, without the programmer having to write extra code. An example hopefully illustrates this point. x ,"1 y=: i.3 4 10

Re: [Jprogramming] Definition: Frame of an argument

2016-01-14 Thread Roger Hui
x=: 10 20 30 in the examples. On Thu, Jan 14, 2016 at 10:57 PM, Roger Hui wrote: > Empty frame, or more accurately zero frames, if it is said to be for > anything, is to allow edge cases, the case where the frame contains a 0, to > work without a lot of exceptions, without the programm

Re: [Jprogramming] Definition: Frame of an argument

2016-01-17 Thread Roger Hui
I did not define them; Roland Pesch did: Empty Frames in SHARP APL , 1986. I did rename them to "zero frames". Read the 1986 paper and you can decide for yourself whether "empty frame" or "zero frame" is the better name. On Sun, Jan 17, 2016 at

Re: [Jprogramming] A Different Less?

2016-01-17 Thread Roger Hui
This is a variant of progressive index-of (pi below). oc=:i.~ (] - {) /:@/: pi=:#@[ ({. i.&(,. oc) }.) [ i. , pless=: [ {~ i.@#@[ -. pi 'abcabbe' pless 'abbe' cab 'Mississippi' pless 'i' Mssissippi 'Mississipp

Re: [Jprogramming] Roll (?) produces domain error on large input

2016-01-17 Thread Roger Hui
I forgot that there is a discussion on ?n where n is an extended precision integer: http://code.jsoftware.com/wiki/Essays/Roll_on_BIGINTs On Mon, Jan 11, 2016 at 7:17 AM, Roger Hui wrote: > Use extended precision integers. > >? !21 > |domain error > | ?!2

Re: [Jprogramming] A Different Less?

2016-01-18 Thread Roger Hui
reduce =: 1 : '<"1@[ ([: i (&.>)/(>@:) ,) <@:]' 'Mississippi' (] {~ i.@#@] -. i.~) reduce~ 'iii' |value error: i | 'Mississippi'(]{~i.@#@]-.i.~)reduce~'iii' More general how? From the looks of it, "reduce" treats the left argument as an array or rank-1 cells. Not very general? On

Re: [Jprogramming] Definition: Frame of an argument

2016-01-18 Thread Roger Hui
t; 20 21 22 23 > >3 (er;fr;cs) YNB. effective rank; frame; cell shape > ┌─┬┬─┐ > │3││2 3 4│ > └─┴┴─┘ > >2 (er;fr;cs) YNB. effective rank; frame; cell shape > ┌─┬─┬───┐ > │2│2│3 4│ > └─┴─┴───┘ > _1 (er;fr;cs) YNB. effective rank; frame; cel

Re: [Jprogramming] Definition: Frame of an argument

2016-01-18 Thread Roger Hui
ments, "outer shape" shows the > dependence on the argument shape and (implicitly) the verb rank. > > I wonder whether we should try to move the documentation in this > direction. There would need to be a general consensus in favor. > > Henry Rich > > On 1/18/2016 11:5

Re: [Jprogramming] Definition: Frame of an argument

2016-01-19 Thread Roger Hui
shape" shows > the > > dependence on the argument shape and (implicitly) the verb rank. > > > > I wonder whether we should try to move the documentation in this > > direction. There would need to be a general consensus in favor. > > > > Henry Rich > >

Re: [Jprogramming] Definition: Frame of an argument

2016-01-19 Thread Roger Hui
ignorance of how cell shape is a better > term is an opportunity to learn. > > Cheers, bob > > > On Jan 19, 2016, at 11:59 AM, Roger Hui > wrote: > > > > The alternative to frame / cell shape being discussed is outer shape / > cell > > shape, not outer shap

Re: [Jprogramming] Definition: Frame of an argument

2016-01-20 Thread Roger Hui
could also be items though :-) > >> > >> Cheers, bob > >> > >>> On Jan 20, 2016, at 10:56 AM, Raul Miller > wrote: > >>> > >>> I thought arrays could hold multiple items? (# counts items?) > >>> > >>> Thanks, &

Re: [Jprogramming] Blonde Code Golf - January Challenge - Alphabet Swap

2016-01-22 Thread Roger Hui
S=: (a.,~,|.t) {~ (a.,~,t=.a.{~97 65+/~i.26)&i. S 'Hello, World!' Svool, Dliow! S 'A man, a plan, a canal, Panama!' Z nzm, z kozm, z xzmzo, Kzmznz! On Fri, Jan 22, 2016 at 5:33 PM, Moon S wrote: > Here's another code golf challenge I found: > > http://www.blonde.net/blog/2016/01/18/

[Jprogramming] k programming challenge

2016-01-26 Thread Roger Hui
http://kxcommunity.com/kx-student-programming-challenge-us-constitution-word-count.php J solution, anyone? -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Behaviour '=' dyad on boolean arrays

2016-02-02 Thread Roger Hui
I don't think it's that significant. In 1=?s$2 the 1= is a no-op. It's there possibly because: - Muscle memory. In APL, in 1-origin, the 1= is needed to convert integers to booleans. - There's a lot of cut-and-paste in making the test scripts. Could have been cut and pasted from somewhere else.

Re: [Jprogramming] Prime Puzzle

2016-02-12 Thread Roger Hui
The sequence has a name: http://en.wikipedia.org/wiki/Primorial On Fri, Feb 12, 2016 at 10:43 PM, Kip Murray wrote: > Cool! --Kip > > On Friday, February 12, 2016, Rob Hodgkinson wrote: > > >ff=: 13 : '*/\p:i.y' > >ff > > [: */\ [: p: i. > >ff each 1 2 3 4 5 6 > > ┌─┬───┬──┬──

Re: [Jprogramming] Non-scalar Newton-Raphson

2016-02-13 Thread Roger Hui
If the atoms of the function are independent, then it's easiest to do f"0 Newton (or f Newton"0) and be done with it. If they are not independent, that is f is what's called a vector function in conventional mathematical notation, then you need to use %. (matrix divide) instead of % (plain old div

Re: [Jprogramming] Non-scalar Newton-Raphson

2016-02-13 Thread Roger Hui
Quoting myself from earlier today: > My knowledge of vector calculus is minimal. Perhaps the mathematicians in this Forum can help you if you really do have a vector function. On Sat, Feb 13, 2016 at 12:32 PM, Louis de Forcrand wrote: > I’m sorry about that Raul, that should read “y”. > > --

Re: [Jprogramming] an inverse to oblique

2016-02-17 Thread Roger Hui
Assuming you know the shape of the original argument: x=: 5 6 ?@$ 100 x -: (;$x)} 5 6$0 1 Deriving the shape of the original x from wrote: > More specific to what I want, based on looking at diagonal relationships > within data, I wish to update a value in the original matrix, but I think

Re: [Jprogramming] an inverse to oblique

2016-02-17 Thread Roger Hui
Instead of portrait and landscape matrices, I myself use tall and wide matrices, terminology I first heard used by Eugene McDonnell. On Wed, Feb 17, 2016 at 11:18 AM, Mike Day wrote: > I started with the rectangular case, so have this rather more complicated > monad: > > deo =: 13 : 's$i{;y[ i

Re: [Jprogramming] Am I understanding m/y ? Expected and not

2016-02-23 Thread Roger Hui
A gerund is a noun, so in +`*`-`- i. 33 it's more accurate to say that i. is applied to the gerund and 33 rather than the gerund is applied to i. , and an easier explanation of why the result is 4. On Tue, Feb 23, 2016 at 6:23 AM, Cliff Reiter wrote: > I think the first time I saw gerund in

Re: [Jprogramming] Am I understanding m/y ? Expected and not

2016-02-23 Thread Roger Hui
> A gerund is a noun ... +`*`-`- ┌─┬─┬─┬─┐ │+│*│-│-│ └─┴─┴─┴─┘ (,&.>'+*--') -: +`*`-`- 1 On Tue, Feb 23, 2016 at 6:39 AM, Roger Hui wrote: > A gerund is a noun, so in +`*`-`- i. 33 it's more accurate to say that > i. is applied to the gerund a

Re: [Jprogramming] Numerator and Denominator

2016-03-08 Thread Roger Hui
x=: %/?2$10^8x x 69904549r40669028 den=: [: % 1 +. ] num=: * den den x 40669028 num x 69904549 On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray wrote: > That's great! It's still a nice puzzle to write your own. --Kip > > On Tuesday, March 8, 2016, Raul Miller wrote: > > >

Re: [Jprogramming] Numerator and Denominator

2016-03-09 Thread Roger Hui
; Mike > > > On 09/03/2016 04:32, Roger Hui wrote: > >> x=: %/?2$10^8x >> x >> 69904549r40669028 >> >> den=: [: % 1 +. ] >> num=: * den >> >> den x >> 40669028 >> num x >> 69904549 >> >>

Re: [Jprogramming] Interweave

2016-03-10 Thread Roger Hui
,|:'ace',:'bdf' abcdef 'ace'([: , |:@,:)'bdf' abcdef On Thu, Mar 10, 2016 at 2:42 PM, Kip Murray wrote: > A quickie -- how do you interweave two equal-length lists, so that > >'ace' itw 'bdf' > abcdef > > --Kip Murray > > > > -- > Sent from Gmail Mobile > -

Re: [Jprogramming] Interweave

2016-03-10 Thread Roger Hui
,'ace',.'bdf' abcdef 'ace',@,.'bdf' abcdef On Thu, Mar 10, 2016 at 2:47 PM, Roger Hui wrote: >,|:'ace',:'bdf' > abcdef >'ace'([: , |:@,:)'bdf' > abcdef > > > On Thu, Mar 10, 201

Re: [Jprogramming] Interweave

2016-03-10 Thread Roger Hui
#x27;bdf' >> >> abcdef >> >> >> ...give the first impression that Ravel puts the items into lexical order, >> >> which is misleading, as shown by the example 2 under Common Uses: >> >> >> ]a =: 4 4 ?@$ 100 >> >> 89 91 1 24 &g

Re: [Jprogramming] Remove trailing zeros

2016-03-30 Thread Roger Hui
rtz=: #~ +./\.@(0&~:) On Wed, Mar 30, 2016 at 8:13 AM, Kip Murray wrote: > How do you remove trailing zeros from a vector? > > rtz 0 1 2 3 > 0 1 2 3 > rtz 0 1 2 0 > 0 1 2 > rtz 0 1 0 0 > 0 1 > rtz 0 0 0 0 > > --Kip Murray > > > -- > Sent from Gmail Mobile > ---

Re: [Jprogramming] Remove trailing zeros

2016-03-30 Thread Roger Hui
There's also rt0=: }.~ -@(#.~)@(0&=) On Wed, Mar 30, 2016 at 8:24 AM, Roger Hui wrote: > rtz=: #~ +./\.@(0&~:) > > On Wed, Mar 30, 2016 at 8:13 AM, Kip Murray > wrote: > >> How do you remove trailing zeros from a vector? >> >> rtz 0

Re: [Jprogramming] Remora: An Array-Oriented Language with Static Rank Polymorphism

2016-04-13 Thread Roger Hui
Olin Shivers, one of the co-authors of the paper, was a judge in the ICFP '98 programming contest. http://www.jsoftware.com/papers/pousse.htm On Wed, Apr 13, 2016 at 6:06 PM, Michal Dobrogost < michal.dobrog...@gmail.com> wrote: > Thought you guys may be interested in this. > > *Full paper:* >

  1   2   3   4   5   6   7   8   >