Or locals:

:: foo ( seq -- a b c )
    0 8 seq subseq
    10 30 seq subseq
    33 80 seq subseq
    [ CHAR: \s = ] tri@ ;


On Sun, Feb 9, 2014 at 7:06 AM, John Benediktsson <mrj...@gmail.com> wrote:

> Maybe something like this:
>
>     : subseqs ( indices seq -- subseqs )
>         [ subseq [ CHAR: \s = ] trim ] curry { } assoc>map ;
>
> You can see it works by returning an array of subseqs:
>
> IN: scratchpad "NAXIS   =                    3 / number of data axes
>                      "
>                 { { 0 8 } { 10 30 } { 33 80 } } swap subseqs .
> { "NAXIS" "3" "number of data axes" }
>
>
> On Sun, Feb 9, 2014 at 5:41 AM, Jean-Marc Lugrin <hb9...@lugrin.ch> wrote:
>
>> Hi,
>> I need to split a string at fixed locations (some of the locations may
>> eventully be calculated, like with a lookup of '/', but at first
>> approximation fixed locations are ok).
>>
>> I came with this example string and quotatiom:
>>
>> "NAXIS   =                    3 / number of data axes
>>        "
>> [  0 swap 8 swap subseq ] [ 10 swap 30 swap subseq ] [ 33 swap 80 swap
>> subseq ] tri [ [ 32 = ] trim ] tri@
>>
>> This works, does the split and trim, but I am not too happy with the
>> multiple swaps. I would liek to keep stack manipulation to the minimum for
>> clarity.
>> Any recommendation ?
>> hb9duj
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>>
>
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to