Re: [Jprogramming] [Jsource] Performance improvement in Jengine - status report

2016-05-25 Thread Raul Miller
On Wed, May 25, 2016 at 4:34 PM, Henry Rich wrote: > We would like a benchmark that uses scalar code heavily. This is the kind > of application that you might say is 'not good for J'. We'd like to make J > better on those applications. If you have some old FORTRAN-style code > written in J, we'd

Re: [Jprogramming] [Jsource] Performance improvement in Jengine - status report

2016-05-26 Thread Raul Miller
/rosettacode.org/wiki/Tonelli-Shanks_algorithm#J >> http://rosettacode.org/wiki/Superpermutation_minimisation#J >> >> I will look at timing those, and you can look into finding more like them. >> >> Henry Rich >> >> >> >> On 5/25/2016 5:08 PM

Re: [Jprogramming] Bring out yer bugs

2016-05-29 Thread Raul Miller
A related problem is, what should you do about something like this? example=: ((3 :0) (2 :0) (3 :0))"1 NB. rightmost verb a: ) NB. conjunction u+v ) NB. leftmost verb 1 2 3+4 5 ) example3=:example2=:example1=:example 13!:0]1 example3 '' |length error:

Re: [Jprogramming] [Jsource] Performance improvement in Jengine - status report

2016-05-29 Thread Raul Miller
gt; http://rosettacode.org/wiki/Levenshtein_distance#J(24% on 1000-byte strings) > > That might be enough to call a test suite, but if you find others I'll check > them too. > > Henry Rich > > > > > > > > > On 5/26/2016 8:19 AM, Raul Miller wrote: >&

Re: [Jprogramming] All unique permutations of a logical vector

2016-05-29 Thread Raul Miller
You probably meant (or +/-.b 0s) for your parenthetical comment. -- Raul On Sun, May 29, 2016 at 6:25 PM, Roger Hui wrote: > What you should be looking at are combinations instead of permutations, > because what you are computing are all the different ways of choosing +/b > 1s (or +/~b 0s) f

Re: [Jprogramming] Help with date formatting

2016-05-30 Thread Raul Miller
Or, going directly from start to finish: aa0=. '4-Apr-1930';'5-Apr-1930';'6-Apr-1930' 10&{.@isotimestamp@getdate each aa0 ┌──┬──┬──┐ │1930-04-04│1930-04-05│1930-04-06│ └──┴──┴──┘ For a little more insight into the grammar, you might want

Re: [Jprogramming] How to tell if all boxes in a row are empty?

2016-06-01 Thread Raul Miller
Or, there's a general pattern leading in the direction of (the incredibly useful) linear algebra: A=:(;:'b c') (0 0;2 2)}3 3$a: */"1 a: = A 0 1 0 a: */ .= A 0 1 0 -- Raul On Wed, Jun 1, 2016 at 8:48 AM, Don Guinn wrote: > I'm not sure just how = goes about comparing boxed da

Re: [Jprogramming] Debug Signal - comments requested

2016-06-01 Thread Raul Miller
Compare these two error cases: 3 :''0 |domain error | 3 :''0 3 :'''example''13!:8]9'0 |example | 'example'13!:8]9 In the first error, the error message is followed by the line containing the error. If I understand your proposal, I think you would have the second example l

Re: [Jprogramming] Debug Signal - comments requested

2016-06-02 Thread Raul Miller
nt is not an integer'(13!:8)123 >> >> NB. f1 gives an error message. >> >> NB. The second line shows the statement containing (13!:8) in f1, the top >> of the stack. >> >> >> 3+f2 'text' >> >> the argument is not an integer

Re: [Jprogramming] Qt or GUI tutorials and information

2016-06-05 Thread Raul Miller
You have seen the "Studio..." option under Help? The labs, in particular, have some good stuff. Don't be afraid to ask, though, if something doesn't seem to work right - there's been quite a lot of version drift since some of that was originally written. Thanks, -- Raul On Mon, Jun 6, 2016 a

Re: [Jprogramming] Qt or GUI tutorials and information

2016-06-07 Thread Raul Miller
your video tutorials worked great on my Win 10 and Linux box > without issue, and the behavior of the popus and buttons was as expected; > no surprises. I would have replied inline, but I did not know how to reply > when the list was being sent as a daily digest. Good work! > > Rob >

Re: [Jprogramming] J-like approach for merging numbers in a list

2016-06-07 Thread Raul Miller
Best I can think of is something like this: mergeMask=: [: ;@(+/\@(0 1&E.) <@(* ~:/\)/. ]) 0, 2 =/\ ] mergeRow=: (-.@] # [ (+/@:{~ <:,:])`(<:@])`[} I.@]) mergeMask Hopefully that makes sense? Thanks, -- Raul On Tue, Jun 7, 2016 at 5:15 PM, Ric Sherlock wrote: > I'm looking for a J-like appr

Re: [Jprogramming] J-like approach for merging numbers in a list

2016-06-07 Thread Raul Miller
27;t handle is the empty arg (which I didn't put in my > spec!). > >mergeRow i.0 > > |length error: mergeRow > > | mergeRow i.0 > > > A quick fix: > mergeRow=: ((-.@] # [ (+/@:{~ <:,:])`(<:@])`[} I.@]) mergeMask) :: ((i.0)"_) > >$mergeRow i.

Re: [Jprogramming] J-like approach for merging numbers in a list

2016-06-08 Thread Raul Miller
That string would not happen in this game - the numbers are always integer powers of 2. However, the result should be 6 6. Marshall's mergerow =: ((*>:) #~ _1|.-.@]) [:>/\.&.|. 0,~ 2 =/\ ] gets it right. Thanks, -- Raul On Wed, Jun 8, 2016 at 12:55 AM, Don Guinn wrote: > Given a string 6 3 3

Re: [Jprogramming] Help me using rank (")

2016-06-08 Thread Raul Miller
Did you mean something like this? (<.0.8*1+i.25) 10&#./."1] 3#,:5# i.5 0 0 0 0 1 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4 0 0 0 0 1 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4 0 0 0 0 1 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4 Except, that doesn't get you those leading zeros for the '01' column, so maybe instead i

Re: [Jprogramming] Help me using rank (")

2016-06-09 Thread Raul Miller
; But I am confused as well about the request for a shape 3 5 5 of what >> appears as a shape 3 45 literal matrix. I do have '01' in mine though. :-) >> >> Cheers, bob >> >>> On Jun 8, 2016, at 10:29 AM, Raul Miller wrote: >>> >>>

Re: [Jprogramming] Help me using rank (")

2016-06-10 Thread Raul Miller
> > 0 0 0 0 01 1 1 >> 1 12 2 2 2 23 3 3 3 34 4 4 4 4 > > 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 >> 4 4 > > 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4 > > But a strange >> thing to want to build. > > On 6/8/2016 1:37 PM, robert therriault wrote:

Re: [Jprogramming] Help me using rank (")

2016-06-10 Thread Raul Miller
t;> Wed, Jun 8, >> 2016 at 5:31 PM, 'Bo Jacoby' via Programming >> >> wrote: > Thanks everyone! > This: >0 2 1|:3 >> 5 5$i.5 > > produces what >> I wanted. > The result is however destroyed in the >> process of emailin

Re: [Jprogramming] Stats example ...

2016-06-13 Thread Raul Miller
Sounds good to me. I updated the page. -- Raul On Mon, Jun 13, 2016 at 12:32 PM, Martin Kreuzer wrote: > Hi all - > > While browsing the J NuVoc page I accidentally stumbled upon this example: > > URL: http://code.jsoftware.com/wiki/Vocabulary/ampdotco > > Under "Common Uses / 2. Compute stand

Re: [Jprogramming] Help me using rank (")

2016-06-14 Thread Raul Miller
There is something wrong with how your email client quotes my email, or how my email system sends them to you, so I am going to trim quotes and reply inline here. On Tue, Jun 14, 2016 at 12:34 PM, Martin Kreuzer wrote: > Your next to last sentence reads, I quote, > "Put differently, we do not nee

Re: [Jprogramming] All anagrams, ignoring reversal

2016-06-15 Thread Raul Miller
There might be a more elegant approach. That said, this (generating all permutations) is an exponential growth algorithm, and your addition does not make that aspect any worse. So, personally, I would not worry about it. Still, it would be nice to find another approach. Thanks, -- Raul On W

Re: [Jprogramming] New 2048 game addon released

2016-06-21 Thread Raul Miller
I tried this, and I noticed some differences from the implementation at https://gabrielecirulli.github.io/2048/ Probably the most significant is that in the original if you have: 2 2 2 And you select the "up" direction, the result is: 4 2 Where currently your J implementation gives: 2 4 Ther

Re: [Jprogramming] New 2048 game addon released

2016-06-21 Thread Raul Miller
bout the merging behaviour. I think I must have mis-read the > spec on Rosetta code. I've fixed it there and on Github now. Will be fixed > in the next release. > > Using arrow keys would be nice - I'm investigating to see if I can make > that happen. > > Cheers, > >

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread Raul Miller
On a tangential note, there are faster ways of doing this. If you are not comfortable with the math, yourself, you might use oeis with some example values and find https://oeis.org/A000330 which suggests F=: 3 :'y*(1+y)*(1+2*y)%6' Is that an adequate solution? F i.10 0 1 5 14 30 55 91 140 204

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread Raul Miller
I need to do a better job of proofreading my messages. In this case I should have said "that implementation uses floating point" or something like that. Sorry about that, -- Raul On Thu, Jun 23, 2016 at 12:23 PM, Raul Miller wrote: > On a tangential note, there are faster ways

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread Raul Miller
4900 > (according to Gardner). - Jud McCranie > <https://oeis.org/wiki/User:Jud_McCranie>, Mar 19 2001, Mar 22 2007 [This > is a result from Watson. - Charles R Greathouse IV > <https://oeis.org/wiki/User:Charles_R_Greathouse_IV>, Jun 21 2013] > Amazing fact! > > O

Re: [Jprogramming] Rearranging rows of tables

2016-06-26 Thread Raul Miller
s p o i l e r s p a c e . . . . . . . . . . f=: [ /: <:@] {"1 [ Or, if you prefer: f=: dyad def 'x /: (y-1) { |:x' Thanks, -- Raul On Sun, Jun 26, 2016 at 8:50 PM, Linda A Alvord wrote: > Design a function f, so D f 3 will arrange the rows in order from small to > lar

Re: [Jprogramming] Rearranging rows of tables

2016-06-26 Thread Raul Miller
> Let me know if this still isn't clear. Linda > > -Original Message- > From: Programming [mailto:programming-boun...@forums.jsoftware.com] On Behalf > Of Raul Miller > Sent: Sunday, June 26, 2016 9:04 PM > To: Programming forum > Subject: Re: [Jprogramming]

[Jprogramming] Average distance between two points in a square

2016-07-04 Thread Raul Miller
I was looking at http://math.stackexchange.com/questions/1294800/average-distance-between-two-randomly-chosen-points-in-unit-square-without-calc and I was wondering how one might perform this calculation in J. It is, of course, fairly straightforward to approximate: (+/ %#)+/&.:*:@:(-/)?2 2 1e

Re: [Jprogramming] Average distance between two points in a square

2016-07-06 Thread Raul Miller
> integrals. I doubt it's possible. And it only gets worse for a cube etc, cus > you'll have a triple integral etc. > > Regards > > On Tue, 7/5/16, Raul Miller wrote: > > Subject: [Jprogramming] Average di

Re: [Jprogramming] Average distance between two points in a square

2016-07-06 Thread Raul Miller
I should probably do a better job of modeling this problem. So, here's an approximate solution which I think models the integration process: F=: (2*#) * */@:-. * +/&.:*: prob=:dyad define NB. x: number of samples for each dimension NB. y: number of dimensions dz=. %x-1 (dz^y)*+/^:_ F"1 >

Re: [Jprogramming] Average distance between two points in a square

2016-07-06 Thread Raul Miller
dimensions which will be treated further in later steps. Or, if that's not viable (and it might not be), then I need some other divide&conqueror approach for this problem. Any hints (even if someone could remind me of a relevant technique's name), that would help. Thanks, -- Raul

Re: [Jprogramming] Use of (@) 'Atop'

2016-07-07 Thread Raul Miller
http://www.jsoftware.com/help/release/random.htm#scode Thanks, -- Raul On Thu, Jul 7, 2016 at 8:37 AM, Martin Kreuzer wrote: > Hi all - > > Approximating Pi using the Monte Carlo method (circle enscribed in unit > square) came up with > >pia=. 13 : '(4 * y %~ +/ 1 >: +/ *: <: +: ? (2,y) $

Re: [Jprogramming] Use of (@) 'Atop'

2016-07-07 Thread Raul Miller
Only for this example. I can construct other examples where ?@ and ?@: give different results. Do you see why? Thanks, -- Raul On Thu, Jul 7, 2016 at 9:35 AM, 'Pascal Jasmin' via Programming wrote: > ? (2,y) $ 0 or u N v N > > > is more formally equivalent to > > > (2,y)?@:$ 0 or N u@:v

Re: [Jprogramming] Use of (@) 'Atop'

2016-07-07 Thread Raul Miller
0 ?@$&>~ i.4 Does that help? Thanks, -- Raul On Thu, Jul 7, 2016 at 10:06 AM, 'Pascal Jasmin' via Programming wrote: > I'd like to see an example. > > > > > ----- Original Message - > From: Raul Miller > To: Programming forum > S

Re: [Jprogramming] Use of (@) 'Atop'

2016-07-07 Thread Raul Miller
(In case this is not obvious, I should note that you will need to add a pair of parenthesis to that example before the actual difference shows up.) -- Raul On Thu, Jul 7, 2016 at 11:23 AM, Raul Miller wrote: >0 ?@$&>~ i.4 > > Does that help? > > Thanks, > > -

Re: [Jprogramming] Average distance between two points in a square

2016-07-07 Thread Raul Miller
I believe quadruple integration for the example of this thread would require a different expression. If you want to buy me a mathematica license, I might be inclined to install it on a machine and test this, but for now, I just think it would look something like this: Int[ Int[ Int[ Int[

Re: [Jprogramming] Use of (@) 'Atop'

2016-07-07 Thread Raul Miller
7, 2016 at 11:32 AM, 'Pascal Jasmin' via Programming wrote: > you meant this: > > 0 ?@:($&>~) i.4 > > don't actually understand why ?@ is different though. > > > > - Original Message - > From: Raul Miller > To: Programming forum > Sent: T

Re: [Jprogramming] Average distance between two points in a square

2016-07-07 Thread Raul Miller
le, once setup, > from your main computer using vnc or ssh. > > On 07/07/2016 11:56 AM, programming-requ...@forums.jsoftware.com wrote: >> >> Date: Thu, 7 Jul 2016 11:40:57 -0400 >> From: Raul Miller >> To: Programming forum >> Subject: Re: [Jprogramming] Avera

Re: [Jprogramming] Using the hypergeometric adverb (H.).

2016-07-07 Thread Raul Miller
Here is one approach: Mn=: 13 :'y H.(-x+1e_7)2'"1 M=: 13 :'|:y Mn 1 2 3,&>/-i.1+y' ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y' I'm not sure if that helps... (I am also slightly dubious about that whole +1e_7 epsilon thing.) -- Raul On Thu, Jul 7, 2016 at 4:53 PM, 'Bo Jacoby' via

[Jprogramming] making rotation matrices

2016-07-10 Thread Raul Miller
I need a routine which makes rotation matrices for a given angle. For example, let's say that my angle is 0.05p1, I would be wanting these two rotation matrices: 3 3$(2 1 o./ (,-)0.05p1) 0 4 1 3}&,=i.3 0.987688 0.156434 0 _0.156434 0.987688 0 00 1 and 3 3$(2 1 o./ (,-)0.0

Re: [Jprogramming] making rotation matrices

2016-07-10 Thread Raul Miller
)"0 > > ptRot =: rx > rlRot =: ry > ywRot =: rz@:- > >ywRot 0.05p1 > 0.987688 _0.156434 0 > 0.156434 0.987688 0 >0 0 1 >ptRot 0.05p1 > 1 00 > 0 0.987688 0.156434 > 0 _0.156434 0.987688 >rlRot 0.05p1 > 0.987

Re: [Jprogramming] making rotation matrices

2016-07-10 Thread Raul Miller
4x4 is not a problem for me. It's trivial to ignore the extra dimension. But euler angle conversion is a problem for me. Specifically, though, https://en.wikipedia.org/wiki/Orbital_elements and https://en.wikipedia.org/wiki/Orbital_state_vectors is where I am trying to focus my attention. Thanks,

Re: [Jprogramming] Are closures possible in J?

2016-07-12 Thread Raul Miller
I did not have any problem with your presentation in http://jsoftware.com/pipermail/programming/2016-July/045440.html (other than a mild reaction to the bulk of code you used for such a simple concept). But, since this topic provokes a lot of back and forth, I suppose it won't hurt to go over it y

Re: [Jprogramming] Question about dyadic verb composition

2016-07-12 Thread Raul Miller
No, but you can make one. For example: x(((<<<_2){{.,@,.}.)[`u`v`w`...`])y I hope this helps. -- Raul On Tue, Jul 12, 2016 at 8:38 AM, dahn oak wrote: > Hello, is there any language cunstruction that is equivalent to: >x u x v x w ... y > where x and y are the arguments of the constr

Re: [Jprogramming] Question about dyadic verb composition

2016-07-12 Thread Raul Miller
ct? Easy enough to test: 10 + 10 - 10 * 10 % 20 15 I hope this helps, -- Raul On Tue, Jul 12, 2016 at 9:19 AM, dahn oak wrote: > Thank you, Raul. It's quite complicated for understanding yet, but I > appreciate it! > > Tue, 12 Jul 2016 09:04:01 -0400 > Raul Miller : >&

Re: [Jprogramming] Question about dyadic verb composition

2016-07-12 Thread Raul Miller
>+`-`*/7 7 7 5 > _21 > > You could wrap this in a function also to do the replication based on $gerund. > > foo > 4 : ' r=:x/(($x),1)#y' > >(+`-`*) foo 7 5 > _21 > > Regards Rob > > >> On 12 Jul 2016, at 11:04 PM, Raul Miller wrote: &

Re: [Jprogramming] making rotation matrices

2016-07-13 Thread Raul Miller
I am a little concerned about the stability of this approach. I extracted your timing test from earlier, and then started playing with normalization. rand=: [: ? ] # 0"_ vv=. 1e6 3$ _1+2*rand 3e6 uu=. norm 1e6 3$ _1+2*rand 3e6 ww=. _1p1+2p1*rand 1e6 echo timespacex'rr=. vv qRot (uu;ww)' echo time

Re: [Jprogramming] challenge: dyad -. but removing the number of copies of x in y

2016-07-25 Thread Raul Miller
(] {~ i.@#@] -. pi~) does not look right, to me. Instead, I think I'd use something like: dfe=: (] #~ #@[ = pi)&.|. Or, perhaps: co=: i:~ (] - {) /:@/: ip=: #@[ ({. i.&(,.co) }.) [ i. , dfe=: (] #~ #@[ = ip) -- Raul On Mon, Jul 25, 2016 at 12:08 PM, 'Pascal Jasmin' via Programm

Re: [Jprogramming] challenge: dyad -. but removing the number of copies of x in y

2016-07-25 Thread Raul Miller
strikeb2 verb (simplified by Roger) [0], > > delfromend=. strikeb2~&.:|. f. > > PS. The verb strikeb2 can be rewritten tacitly as, > strikeb2=. [ #~ (i.~ (] - {) /:@/:)@:[ >: ([ i.~ ~.@:]) { 0 ,~ #/.~@:] > > [0] [Jforum] Custom fit and set functions > http://

Re: [Jprogramming] Adverbial Tacit Jym

2016-08-02 Thread Raul Miller
Yes, of course there is. Starting with the obvious: kludge=: '@:(o.@:(%&3))'Cloak@:('/.'Cloak@:(('`'Cloak@('&o.'Cloak)each ))) junk=: 4 :'kludge x y' But I expect you will be asking for a tacit expression, instead of the junk I am presenting here, and that's doable also - though I suspect tha

Re: [Jprogramming] Adverbial Tacit Jym

2016-08-15 Thread Raul Miller
Er... if I remember right, you are not talking about the J we can download from jsoftware.com but your modified version? Thanks, -- Raul On Sun, Aug 14, 2016 at 11:16 PM, Jose Mario Quintana wrote: > I forgot to emphasize, is better late than never, that fully fixed tacit > (no compromises) c

Re: [Jprogramming] Adverbial Tacit Jym

2016-08-15 Thread Raul Miller
))@:(<@:((0;1;0)&({::@:[) > ))((`_)(`:6))) > > Why did you ask? Perhaps because some of my statements were > misleading or unclear > to you? Maybe you think I made a mistake (which definitely I am quite > capable of making)? > > > [0] [Jprogramming] T

Re: [Jprogramming] Gustafson's Unums Revisited

2016-08-16 Thread Raul Miller
cd is defined as part of the base system. http://www.jsoftware.com/help/user/call_procedure.htm chdir would be 1!:44 if it were defined. http://www.jsoftware.com/help/dictionary/dx001.htm I hope this helps, -- Raul On Tue, Aug 16, 2016 at 4:40 PM, Skip Cave wrote: > Robert, > > Starting th

Re: [Jprogramming] Gustafson's Unums Revisited

2016-08-16 Thread Raul Miller
num files are, which is > > > C:/Users/Skip/j64-804/projects/unum (where the utils.ijs file is located) > > > So I tried: > > > 1:!44 '~projects\unum' > > |syntax error > > | 1:!44'~projects\unum' > > Still no luck. > &g

Re: [Jprogramming] Gustafson's Unums Revisited

2016-08-17 Thread Raul Miller
Yes. ({.~ i:&'/');(4!:4 <'is_unum') { 4!:3'' gives the directory where unum's utils.ijs was loaded from. (And this can even be done in that same script, after is_unum has been defined.) That said, for the long run, it would probably be better to stuff this in a variable and use it where neede

Re: [Jprogramming] Gustafson's Unums Revisited

2016-08-17 Thread Raul Miller
unums are lossy, by design. The losses were chosen to give plausible results for certain equations involving zero. Also, you can use JNFS"0 and SFJN"0 if you want to deal with vectors. Or, maybe give those names... Thanks, -- Raul On Wed, Aug 17, 2016 at 10:02 AM, Skip Cave wrote: > Playing

Re: [Jprogramming] Gustafson's Unums Revisited

2016-08-18 Thread Raul Miller
Actually, J usually stores the number in whatever format it happens to be storing it as. However, when J displays the number, it routinely removes irrelevant information. Something similar happens when you enter numbers. Thus: 2j0 2 datatype 2j0 integer 1j1 + 1j_1 2 datatype 1j1 + 1

Re: [Jprogramming] Gustafson's Unums Revisited

2016-08-18 Thread Raul Miller
the interval 0j0.5 and everything's ok. > Unfortunately, not the mirror interval on the negative side. > > > Skip > > > > Skip Cave > Cave Consulting LLC > > On Thu, Aug 18, 2016 at 3:49 PM, Raul Miller > wrote: > > > Actually, J usually stores th

Re: [Jprogramming] Gustafson's Unums Revisited

2016-08-19 Thread Raul Miller
> Skip > > Skip Cave > Cave Consulting LLC > > On Thu, Aug 18, 2016 at 6:04 PM, Roger Hui > wrote: > >>cmpx=: j.&0 >> >>datatype cmpx 1 0 >> complex >>datatype cmpx 3 4 >> complex >>datatype cmpx 5.

Re: [Jprogramming] Jolf

2016-08-20 Thread Raul Miller
Er... for something like this, I would probably start with one of Roger's implementations from http://code.jsoftware.com/wiki/Essays/N_Queens_Problem #;:queenst f. 1 :'5!:5<''u''' 42 Looks like yours is more concise though. I hope this helps... -- Raul On Sat, Aug 20, 2016 at 6:49 PM, Lou

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
That is not a cycle. (1+i.26) -. {."1 edges 8 19 24 -- Raul On Thu, Aug 25, 2016 at 6:13 AM, R.E. Boss wrote: > Given the edges in a graph which is a cycle, like >edges > 1 2 > 3 1 > 2 4 > 4 5 > 5 6 > 6 7 > 7 8 > 9 8 > 10 9 > 11 10 > 11 12 > 12 13 > 14 15 > 15 16 > 17

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
Best I can come up with is {."1 ((] , -. {~ {.@I.@(-. +./"1@e. {:@]))^:(<:@#@[) ,:@{.) edges 1 3 17 18 18 20 20 21 22 14 15 16 23 26 25 13 12 11 11 10 9 7 6 5 4 2 Change {.@I. to {:@I. if you want things in the other order. -- Raul

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
t some vertices and duplicates others. > > > -------- > On Thu, 8/25/16, Raul Miller wrote: > > Subject: Re: [Jprogramming] determine the cycle > To: "Programming forum" > Date: Thursday, August 25, 2016, 9:07 PM > > Best I can come up with > is > >

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
ot;1 > {:x'))^:(#@>@{:) ({.;}.) edges > 1 2 4 5 6 7 8 9 10 11 12 13 24 25 26 23 16 15 14 22 21 20 19 18 17 3 1 > > > R.E. Boss > > >> -Original Message- >> From: Programming [mailto:programming-boun...@forums.jsoftware.com] >> On Behalf

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
2016 at 5:50 PM, Louis de Forcrand wrote: > I think the 2 at the beginning of your solution (1 _2_ 3 17 …) should be at > the end. > > Cheers, > Louis > >> On 25 Aug 2016, at 23:21, Raul Miller wrote: >> >> I am more than willing to believe that I have

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
-- Raul On Fri, Aug 26, 2016 at 1:26 AM, R.E. Boss wrote: > I share this talent: 2 is not adjacent to 3 was what I meant. > > > R.E. Boss > > >> -Original Message- >> From: Programming [mailto:programming-boun...@forums.jsoftware.com] >> On Be

Re: [Jprogramming] Geometric Mean definition ...

2016-08-26 Thread Raul Miller
Yes: 5^441 442 1.76105e308 _ Thanks, -- Raul On Fri, Aug 26, 2016 at 5:38 PM, Brian Schott wrote: > Martin, > > Your examples of gm0 failing are not clear to me because you use random > data. > I tried the following nonrandom data, but a sort of random case where the > number of data value

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-02 Thread Raul Miller
Actually, if we try your approach on -8 2 4 3 1 6 we get _8 _2 _1 instead of _8 _4 _3 _1. Here's a brute force O(2^n) approach that I hacked up earlier - it obviously only works on short lists: increasing=: (-: /:~)@#~"1 #:@i.@^~&2@# longestinc=: ] #~ [: (#~ ([: (= >./) +/"1)) #:@I.@increasing W

Re: [Jprogramming] Count and say

2016-09-02 Thread Raul Miller
Or, to generate the counting sequence of such numbers, see: https://www.rosettacode.org/wiki/Look-and-say_sequence#J Thanks, -- Raul On Fri, Sep 2, 2016 at 5:09 AM, Henry Rich wrote: > See http://code.jsoftware.com/wiki/Essays/Advent_Of_Code#Part_1_10 > > Henry Rich > > > On 9/2/2016 12:42 A

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-02 Thread Raul Miller
> Subject: Re: [Jprogramming] Greatest Increasing Subsequence > > To: 'Mike Day' via Programming > > > > Same problem with my version, which was faster but equally wrong! Mike On > 02/09/2016 14:57, Raul Miller wrote: > Actually, if we try your approach on &g

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-02 Thread Raul Miller
lt;_) ; ] >c=.[: > s {~ [: {.@\: #@>@s >g=.}.@n ;~ {.@n ; s h {.@n >n=.>@{: >s=.>&{. >h=.[: ; e&.> >e=.<@[`([ ; [ , ])@.t >t=.{:@[ < ] >f 7 4 4 5 2 7 1 8 13 2 10 4 9 1 4 5 5 4 3 10 3 4 5 8 15 7 11 19 > 1 2 3 4 5

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-09 Thread Raul Miller
One thing I keep meaning to do, when i see stuff like this, is verify that the various versions are giving the same results for the same test arguments. (In the past, I have seen timing examples where we were comparing timings on code that gave different results.) I haven't done that here, yet, bu

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-09 Thread Raul Miller
4 17 20 > > 4 5 9 13 14 17 20 > > lisXR a > > 0 1 3 13 14 17 20 > > lisEH a > > 0 1 3 13 14 17 20 > > > Cheers, > Erling > > > > On 2016-09-09 16:02, Raul Miller wrote: >> >> 1=#~.(lisI; lisJ; lisM; lisL; lisEH) a &g

Re: [Jprogramming] GET POST http utilities.

2016-09-12 Thread Raul Miller
I use the curl which is bundled in cygwin. So far, it has worked fine with https. That said, I am trying to remember if I had to install some certificates on my machine for that to work. You might try adding --insecure to your curl command line options and seeing if that makes it work. Thanks,

Re: [Jprogramming] Counting characters

2016-09-13 Thread Raul Miller
You might try these: require'trace' trace'+/"1''abc''=/''abcbdefbbcbaa''' trace'(+/"1''abc''=/])''abcbdefbbcbaa''' This does not show everything, but does take you through the parsing process up to where the error happens in the second statement. (Also, beware of email agents which chan

Re: [Jprogramming] Counting characters

2016-09-13 Thread Raul Miller
The easy way to make a tacit verb (and worth trying whenever you feel "stuck") is to use 13 : (remember the space preceding the :). 13 :'+/"1''abc''=/''abcbdefbbcbaa''' 3 5 2"_ Of course, you probably wanted a verb argument instead of just having that constant in there, so: 13 :'+/"1''abc'

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-16 Thread Raul Miller
The boxing is a measurable performance issue, since you wind up doing a lot of boxed operations. The reversing is not a measurable performance issue, since it only happens twice and because the overall algorithm is does so much more work. Both of these are "conciseness" issues, however. But if co

Re: [Jprogramming] A Complaint with Format

2016-09-23 Thread Raul Miller
This is not a property of format, but a property of numbers. These are numerically equivalent: 1 01 001 0001 1 01 001 0001 and so on... If you are concerned with the textual distinction you should be working with text and not numbers. Thanks, -- Raul

Re: [Jprogramming] A Complaint with Format

2016-09-23 Thread Raul Miller
Or: _5{.":1e9+1 1 _5{.":1e9+34 00034 _5{.":1e9+340 00340 _5{.":1e9+3400 03400 You can use extended precision if you need more than 18 digits... FYI, -- Raul On Fri, Sep 23, 2016 at 5:13 PM, robert therriault wrote: > Working with Bjorn's suggestion, you could do this > >

Re: [Jprogramming] GET POST http utilities.

2016-09-24 Thread Raul Miller
Further note: gethttp uses the instance of curl installed in addons/web/gethttp/bin/curl.exe Currently, this is being built without libssl support, which is why gethttp fails with https urls. This probably should be fixed, given how prevalent https is becoming (boosted by hostile activities on t

Re: [Jprogramming] GET POST http utilities.

2016-09-26 Thread Raul Miller
icial website, > * https://curl.haxx.se/download.html > > Which one is the best for inclusion in J addons? > > Сб, 24 сен 2016, Raul Miller написал(а): >> Further note: >> >> gethttp uses the instance of curl installed in >> addons/web/gethttp/bin/curl.exe >>

Re: [Jprogramming] Learning Recursion

2016-09-27 Thread Raul Miller
^: is induction, not recursion. You should use either $: or a named routine if you want recursion. Also, ^: is defined such that the left argument is constant and the right argument is the result of the previous function evaluation. (Or, initially, the initial right argument.) Still, you can sort

Re: [Jprogramming] Learning Recursion

2016-09-27 Thread Raul Miller
never come back to the first. This has some obvious advantages, especially when it's what you wanted in the first place. Thanks, -- Raul On Tue, Sep 27, 2016 at 3:55 AM, Raul Miller wrote: > ^: is induction, not recursion. You should use either $: or a named > routine if you want

Re: [Jprogramming] Zig Zag problem

2016-09-28 Thread Raul Miller
I am not Henry. It looks like you already caught that, but ... ...just saying, -- Raul On Wed, Sep 28, 2016 at 6:58 AM, Erling Hellenäs wrote: > Hi all ! > > My solution, sort version: > > NB. Erling > > ZigZagE=:([: /: ] (([: $ [) $ ]) [: (], [: |. [: }: }.) [: i. [) { ] > > NB. Mike > > st

Re: [Jprogramming] Learning Recursion

2016-09-29 Thread Raul Miller
To follow up on the message I sent off-list, here's some perspective on how to construct an inductive implementation of remove-every-nth. First, let's get a non-numeric list to remove every nth, from: 'abcdefghij' abcdefghij Second, if we are going to remove every third element, inductively,

Re: [Jprogramming] Non-mutable arrays

2016-10-01 Thread Raul Miller
On Sat, Oct 1, 2016 at 10:23 AM, Marshall Lochbaum wrote: > J's arrays are immutable in normal use. When you write (2 (7}) a), J > makes a new copy of (a), changes the value at index 2 to a 7, and > returns that array, which is now unrelated to (a). There's no way to > modify the original array us

Re: [Jprogramming] Non-mutable arrays

2016-10-01 Thread Raul Miller
Oops, it looks like Henry beat me to the punch, and that I had overlooked his message. Oh well, repetition can sometimes be a good thing. Thanks, -- Raul On Sat, Oct 1, 2016 at 12:07 PM, Henry Rich wrote: > Yep, that's how it works. Temporary results can be operated on in-place. > Also name

Re: [Jprogramming] Non-mutable arrays

2016-10-02 Thread Raul Miller
I don't think that scalar languages vs. array languages is the issue, here. Thanks, -- Raul On Sun, Oct 2, 2016 at 9:32 AM, Don Guinn wrote: > Scalar languages have a need for non-mutable arrays. Array languages do > not. As Bill said, all arrays in J are non-mutable. But names are not. As I

Re: [Jprogramming] Non-mutable arrays

2016-10-02 Thread Raul Miller
mory location > are synonymous. So the issue of non-mutable arrays and non-mutable names > are synonymous. In J they are not. > > > On Oct 2, 2016 8:29 AM, "Raul Miller" wrote: > >> I don't think that scalar languages vs. array languages is the issue, here. >&

Re: [Jprogramming] Non-mutable arrays

2016-10-02 Thread Raul Miller
bs don't look like they lend themselves to update in > place anyway. But that's what the beta is for. To make sure that the update > in place logic won't result in corrupted arrays. > > I'm not familiar with Forth. If it provides looping and updating in place > even o

Re: [Jprogramming] Non-mutable arrays

2016-10-03 Thread Raul Miller
This has been bothering me. After sleeping on it, I think I know how to articulate my concerns: It seems unnecessary. First, the error handling in this case could restore the shape of a to its original value and that seems like it should be simple. However, also, in hypothetical analogous cases

Re: [Jprogramming] Non-mutable arrays

2016-10-03 Thread Raul Miller
(a) trick, while clever, does not work in the implementation > because (a =: 0) does not actually reduce the usecount of a until the > sentence completes. > > Henry Rich > > > On 10/3/2016 7:21 PM, Raul Miller wrote: >> >> This has been bothering me. After sleeping

Re: [Jprogramming] Non-mutable arrays

2016-10-03 Thread Raul Miller
they provide; I think the new changes have even higher bang for the buck. > > hr > > > > On 10/3/2016 9:50 PM, Raul Miller wrote: >> >> I mentioned (a=:0](a) because we seem to be talking about changing the >> implementation. >> >> Specifically, if we a

Re: [Jprogramming] Non-mutable arrays

2016-10-03 Thread Raul Miller
uld be no way to restore (a). > > And in general, many in-place verbs may have executed before the error. The > original (a) may be long gone. > > If you foresee this as a problem, you should execute 9!:53(0) to turn off > early assignment. > > Henry Rich > > On 1

Re: [Jprogramming] assert and assert.

2016-10-04 Thread Raul Miller
assert is based on 13!:8 http://www.jsoftware.com/help/dictionary/dx013.htm assert. is documented at http://www.jsoftware.com/help/dictionary/cassert.htm One significant difference is that you can turn off assert. after you are done testing (if the performance cost becomes significant) using 9!:3

Re: [Jprogramming] Early assignment WAS: Non-mutable arrays

2016-10-04 Thread Raul Miller
t; Since there's only one operation, if it fails a shouldn't be modified >> should it? >> If so, copying a at the beginning of a tacit verb containing more than one >> in-place operation (IPO) should always be faster than the current >> implementation, since copying wo

Re: [Jprogramming] Non-mutable arrays

2016-10-06 Thread Raul Miller
Probably not the right forum for this? Or, at least, this doesn't work for me, in J. Maybe chat would work. -- Raul On Thu, Oct 6, 2016 at 4:33 AM, Erling Hellenäs wrote: > Hi all ! > > This test with an immutable list class shows how you can get a copy with one > changed element in 12 micros

Re: [Jprogramming] Generating Lookup Tables (LUTs)

2016-10-12 Thread Raul Miller
I'm not quite sure I understand what you are doing here. Here's what I understand from your description: You're looking for rows where a bit set in X has a bit set in Y, and you want to split up X and Y into smaller pieces for your intermediate result, and you want to use indices rather than bit

Re: [Jprogramming] Generating Lookup Tables (LUTs)

2016-10-13 Thread Raul Miller
> I would describe the higher level operation as: select the rows of Y where > X is 1. Then take the column-wise OR of them. > > However the real thing I'm interested in is generating the lookup tables > which serve as an intermediate step in the higher level operation. > >

<    4   5   6   7   8   9   10   11   12   13   >