If you want to flatten, you could do this:

    IN: scratchpad { { 1 2 } { 3 4 } } concat .
    { 1 2 3 4 }

If you want to just check the rows for membership, you could do this (which
checks if any of the rows contained in the matrix contain the a particular
number):

    IN: scratchpad 5 { { 1 2 } { 3 4 } } [ member? ] with any? .
    f

    IN: scratchpad 3 { { 1 2 } { 3 4 } } [ member? ] with any? .
    t

Your "contain a number greater than n" check might be:

    IN: scratchpad 5 { { 1 2 } { 3 4 } } [ [ < ] with any? ] with any? .
    f

    IN: scratchpad 3 { { 1 2 } { 3 4 } } [ [ < ] with any? ] with any? .
    t

These might look "cleaner" if you re-ordered it and used fry notations (or
not, just an idea):

    IN: scratchpad { { 1 2 } { 3 4 } } 5 '[ _ swap member? ] any?

    IN: scratchpad { { 1 2 } { 3 4 } } 5 '[ [ _ > ] any? ] any?




On Wed, Jan 9, 2013 at 7:46 PM, Leonard P <leonard14...@gmail.com> wrote:

> Was thinking of writing a word called fibonacci? ( n -- ? ).
>
> The definition would iteratively compute m^n of { { 0 1 } { 1 1 }.
>
> The iteration terminates when the matrix either contains n or a value
> greater than n.
>
> If the matrix contains n, then push t.
>
> If the matrix contains a value greater than n, then push f.
>
> First step is to be able to flatten a matrix into a 1-D array.
>
> Anyone know how?
>
>  - Leonard
>
>
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122712
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to