[Jprogramming] How to choose characters with a boolean mask?
Don Guinn
donguinn at gmail.com
Fri Apr 16 18:48:59 UTC 2021
And more interesting things.
2j1 1 0j1 1#!.'*' 'abcd'
aa*b*d
On Fri, Apr 16, 2021, 10:34 AM Devon McCormick <devonmcc at gmail.com> wrote:
> For replacing the masked characters:
> mask}chars,:'.' NB. Replace with .s
> A.CD.F.HIJKLM
> or
> 'XYZ' (I.mask)}chars NB. Replace with specific characters
> AXCDYFZHIJKLM
>
> On Fri, Apr 16, 2021 at 10:28 AM Jimmy Gauvin <jimmy.gauvin at gmail.com>
> wrote:
>
> > You might also be interested in the inverse of copy
> >
> > 1 0 0 0 1 0 1 #^:_1 'abc'
> >
> > a b c
> >
> >
> > I remember I had a hard time finding expand
> >
> > On Fri, Apr 16, 2021 at 1:53 AM ethiejiesa via Programming <
> > programming at jsoftware.com> wrote:
> >
> > > Is monadic # what you're looking for?
> > >
> > > mask # chars
> > > BEG
> > >
> > > HH PackRat <hhpackrat at gmail.com> wrote:
> > > > Hello, all!
> > > >
> > > > I have a list of characters and a boolean list of 1s and 0s. I
> > > > thought that I could use the boolean list as a "mask" to choose
> > > > characters by using "and" (*.). But the definition in NuVoc
> basically
> > > > states that it can only be used with numbers (no literals).
> > > >
> > > > Here's an example of the kind of thing I'd like to be able to do:
> > > >
> > > > chars=. 'ABCDEFGHIJKLM'
> > > > mask=. 0 1 0 0 1 0 1 0 0 0 0 0 0 [boolean values]
> > > >
> > > > mask2=. 0 1 0 0 4 0 6 0 0 0 0 0 0 [positions of boolean values]
> > > >
> > > > I thought that I could do something like chars *. mask to get the
> > > > result BEG. That doesn't work nor does converting the mask to
> > > > position numbers (mask2) work. So how *can* I mask the characters?
> > > > I'd be interested in knowing both the "pure" boolean kind of approach
> > > > (1s and 0s only) as well as a positional approach that I can use with
> > > > amending.
> > > >
> > > > My ultimate goal is actually to amend the masked characters to be a
> > > > different character(s). I hope I've given enough information. (The
> > > > example, of course, is completely "fake", but I hope it gives the
> idea
> > > > of what I'm trying to do.)
> > > >
> > > > Thanks for any help!
> > > >
> > > > Harvey
> > > >
> ----------------------------------------------------------------------
> > > > For information about J forums see
> http://www.jsoftware.com/forums.htm
> > >
> > >
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
>
> --
>
> Devon McCormick, CFA
>
> Quantitative Consultant
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
More information about the Programming
mailing list