Notice that 2 and 'b' have different type, so 2 'b' gives a syntax error.

If you want character patterns recognised do something like

   (2;'b') pattern & chr 'xxxxxxxxxxxxxxxxxbbxxxxxxxbbbxxxx'
17

where
   chr=: 3 : 'if. 32=(3!:0)y do. (,a.&i.)&>/y else. a.i.y end.'


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:programming-
> [EMAIL PROTECTED] Namens Richard Donovan
> Verzonden: dinsdag 6 november 2007 10:06
> Aan: Programming forum
> Onderwerp: RE: [Jprogramming] My first adverb - doesn't work!
> 
> 
> Henry said...
> >
> > CHAR =: &(a.&i.)
> >
> > Henry Rich
> >
> 
> Thanks Henry, that works fine for the examples I stated
> 
>    'a'> CHAR 'b'
> 0
>    'a' < CHAR 'b'
> 1
> 
> but I was hoping for an adverb that would handle most anything, for
> example Raul's brilliant
> pattern match in a recent thread:
> 
> Raul said...
> 
>    pattern=: (1 #~ [EMAIL PROTECTED]) [EMAIL PROTECTED]&(0 , 0 ,~ ]) ] e. {:@[
>    dat=:0 7 8 8 8 9 2 2 5 5 5 3 8 8 8 0 0 5 5 9 6 8 8 8 8 4 0 6 4
>    2 5 pattern dat
> 17
> 
> 
> but...
> 
>    dat=:'xxxxxxxxxxxxxxxxxbbxxxxxxxbbbxxxx'
>    2 'b' pattern CHAR dat
> |syntax error
> |       2'b'pattern CHAR dat
> 
> I can get round it by the convoluted...
>    x1=: a.i.'b'
>    x2=: a.i.'xxxxxxxxxxxxxxxxxbbxxxxxxxbbbxxxx'
>    (2,x1) pattern x2
> 17
> 
> ...but would rather have a "neater" inline version!
> 
> 
> In other words, I want the transforms from character to numeric to occur
> BEFORE the verb operates but without the verbosity. And I want it to work
> with ANY verb!
> 
> Perhaps I don't need an adverb (which I'm advised only takes ONE
> argument), but rather a different
> construction which I haven't studied yet?
> _________________________________________________________________
> 100's of Music vouchers to be won with MSN Music
> https://www.musicmashup.co.uk---------------------------------------------
> -------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to