Hi Phil, Try using multimethods. You'll need to unpack your 3-element sequence first, though.
USE: multi-methods GENERIC: foo METHOD: foo { integer string integer } ... ; { 1 "hello" 3 } first3 foo Slava On 4-Mar-08, at 9:29 AM, 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