Re: [Jprogramming] locating indices of string in list of strings

2014-08-30 Thread Don Kelly
Tally works whether or not the first element is 0 or 1 and,while I used index 1 as default in APL, I will stick with index 0 in J as it saves a lot of hassle. Don On 30/08/2014 5:21 PM, robert therriault wrote: Whoops, Don, for some reason I got it into my head that you wanted to keep the fi

Re: [Jprogramming] locating indices of string in list of strings

2014-08-30 Thread Don Kelly
Thank you,Raul, Robert and Linda I tried # just before opening my e-mail and getting your answers. I am kicking myself because I have previously used # this way but this time my APL got in the way and I was looking at some variation of " /" Don Kelly On 30/08/2014 4:51 PM, Raul Miller wrote:

Re: [Jprogramming] locating indices of string in list of strings

2014-08-30 Thread robert therriault
Whoops, Don, for some reason I got it into my head that you wanted to keep the first zero. Nub would work against you in that case as it would hold on to the first zero and remove the rest. You could always just remove the 0 using Less (-.) in this case the Passive version (-.~) 0-.~ ( i.#

Re: [Jprogramming] locating indices of string in list of strings

2014-08-30 Thread Raul Miller
apl: 1 0 1 0 1 / 1 2 3 4 5 1 3 5 J: 1 0 1 0 1 # 1 2 3 4 5 1 3 5 apl: 1 0 1 0 1 \ 1 3 5 1 0 3 0 5 J: 1 0 1 0 1 #inv 1 3 5 1 0 3 0 5 Thanks, -- Raul On Sat, Aug 30, 2014 at 7:30 PM, Don Kelly wrote: > My intent was to strip the non essential zeros . the original boolean vect

Re: [Jprogramming] locating indices of string in list of strings

2014-08-30 Thread robert therriault
Hi Don, I think that copy (#) combined with increment (>:) may be able to do the trick. 1 1 0 0 1#i.5 NB.index 0 0 1 4 1 1 0 0 1>:@#i.5 NB.index 1 1 2 5 Although reading through your journey to get to this point I wonder if Nub (~.) would do the trick. arr ab cd yyy jcd ab cd y

Re: [Jprogramming] locating indices of string in list of strings

2014-08-30 Thread Linda Alvord
1 1 0 0 1#i.5 0 1 4 1 1 0 0 1 #>:i.5 1 2 5 Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Don Kelly Sent: Saturday, August 30, 2014 7:31 PM To: programm...@jsoftware.com Subject: Re: [Jprogra

Re: [Jprogramming] locating indices of string in list of strings

2014-08-30 Thread Don Kelly
My intent was to strip the non essential zeros . the original boolean vector based on the inside expression +./"1 'cd' E."1 arr and multiplied by i.#arr gave 0 1 0 3 0 5 0 7 0 9 for which the indices of interest are 0(first one)1 3 5 7 To be able to account for the first index being 0 , I added 1

Re: [Jprogramming] string interpolation

2014-08-30 Thread Raul Miller
That does what I needed. Thanks, -- Raul On Sat, Aug 30, 2014 at 11:35 AM, June Kim (김창준) wrote: > Hi > > Is this what you want? (Note: \n is a backreference to n-th match of the > pattern) > > assert '**123*'-:('[0-9]+';'**\0*') pysub '123' > > assert 'ab 123*y*45 de'-:('([0-9]+)([x]+)([0-9]

Re: [Jprogramming] bug in rxapply (and rxfrom)?

2014-08-30 Thread Raul Miller
Note that this works: 'a' |. rxapply ,'A' Thanks, -- Raul On Sat, Aug 30, 2014 at 11:53 AM, June Kim (김창준) wrote: > Hello > > I accidentally have found a bug in rxapply, which actually resides in > rxfrom. > > Have a look at a simple demonstration of the bug: > >'a' |. rxapply 'A' > >

Re: [Jprogramming] string interpolation

2014-08-30 Thread 김창준
Due to rxapply(and rxfrom) bug that I posted a minute ago, you have to currently do the following when the replacement pattern's length is 1: ('AND';,:'&') pysub 'alpha AND bravo' alpha & bravo Or, you may switch the definition of rxfrom in regex.ijs to the commented-out one. On Sun, Aug 3

[Jprogramming] bug in rxapply (and rxfrom)?

2014-08-30 Thread 김창준
Hello I accidentally have found a bug in rxapply, which actually resides in rxfrom. Have a look at a simple demonstration of the bug: 'a' |. rxapply 'A' |length error: rxfrom | r=.u&.>mat rxfrom y I think that is a bug. It should return the original string if nothing is to be matched and

Re: [Jprogramming] string interpolation

2014-08-30 Thread 김창준
Hi Is this what you want? (Note: \n is a backreference to n-th match of the pattern) assert '**123*'-:('[0-9]+';'**\0*') pysub '123' assert 'ab 123*y*45 de'-:('([0-9]+)([x]+)([0-9]+)';'\1*y*\3') pysub 'ab 123x45 de' assert ' https://www.jsoftware.com/wiki/help/pcre/pcrepattern.html'-:('http://(

Re: [Jprogramming] Running a video game loop

2014-08-30 Thread mvillarino
> However, for a video game with any more than > rudimentary complexity, one would wish to separate "frames" (drawing the > image to the screen) from "ticks" (computing the game logic). Preferably, > ticks would happen at a constant rate per second, and then the remaining > computation time would b

Re: [Jprogramming] string interpolation

2014-08-30 Thread Raul Miller
Actually, that's buggy. I should have said: mid=. (,:({:-{.@,,0:)M) rxcut 1{::segs Oops... -- Raul On Sat, Aug 30, 2014 at 4:13 AM, Raul Miller wrote: > J has "PCRE" regular expressions: > >require 'regex' >url=: 'http://www.jsoftware.com/help/pcre/pcrepattern.html' >>('http:

[Jprogramming] string interpolation

2014-08-30 Thread Raul Miller
J has "PCRE" regular expressions: require 'regex' url=: 'http://www.jsoftware.com/help/pcre/pcrepattern.html' >('http://[^/]+'&rxmatch rxcut ]) url http://www.jsoftware.com /help/pcre/pcrepattern.html Now.. regular expressions seem like they ought to be a natural fit for J - if nothing