Ah - now that's a sweet idea. It never occurred to me to use predicate 
classes with a builtin superclass.

! RENAME ME
: 3match? ( seq quot quot quot -- ? ) 3array [ call ] 2all? ;

PREDICATE: array something [ fixnum? ] [ fixnum? ] [ string? ] 3match? ;
PREDICATE: array something2 [ fixnum? ] [ string? ] [ string? ] 3match? ;

GENERIC: doit
M: something doit ... ;
M: something2 doit ... ;

Thanks v. much!

-Phil


Daniel Ehrenberg wrote:
> Well, I'm glad you found that (I certainly didn't realize that
> possibility when I read your first mail) but I'm not sure if this is
> the appropriate thing to use inverse for. It might make more sense to
> use predicate classes.
> 
> Dan
> 
> On Tue, Mar 4, 2008 at 10:40 AM, Phil Dawes <[EMAIL PROTECTED]> wrote:
>> D'oh!
>>
>>  dup first3
>>  {
>>    { [ _ >fixnum _ >fixnum _ >string ] [ dosomething ] }
>>    { [ _ >fixnum _ >string _ >fixnum ] [ dosomething2 ] }
>>  } switch
>>
>>  Cheers,
>>
>>  Phil
>>
>>
>>
>>  Phil Dawes wrote:
>>  > Hi Dan, Hi Factor List
>>  >
>>  > Last night I was looking for a pattern matching library and found your
>>  > post on extra/inverse. I just wanted to check that I'm not missing a 
>> trick:
>>  >
>>  > I want to match 3 elt sequences, but after the match I want the seq as
>>  > it was (i.e. not destructured). I'm doing the following:
>>  >
>>  > e.g. matching { 1 "hello" 3 }
>>  >
>>  > {
>>  >      ! this one doesn't match
>>  >      { [ >r >r >fixnum r> >fixnum r> >string 3array ] [ 3array
>>  > dosomething ] }
>>  >
>>  >      ! this one matches
>>  >      { [ >r >r >fixnum r> >string r> >fixnum 3array ] [ 3array
>>  > dosomething2 ] }
>>  >
>>  > } switch
>>  >
>>  > Is this a reasonable way to achieve this with inverse or am I
>>  > overlooking something simpler?
>>  >
>>  > Many thanks,
>>  >
>>  > Phil
>>  >
>>  >
>>  >
>>  > -------------------------------------------------------------------------
>>  > This SF.net email is sponsored by: Microsoft
>>  > Defy all challenges. Microsoft(R) Visual Studio 2008.
>>  > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>  > _______________________________________________
>>  > Factor-talk mailing list
>>  > Factor-talk@lists.sourceforge.net
>>  > https://lists.sourceforge.net/lists/listinfo/factor-talk
>>  >
>>
>>
>>
>>
> 



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to