Hello!

I'm pretty new to factor and have run into an issue related to the
"call" word that I'm hoping one of you can help me understand.

Basically what it comes down to is I'm trying to use the 1|| word (which
runs "call") and a vector of fry'd quots:

-----------------------------------

! Copyright (C) 2011 Matt Edlefsen.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel fry sequences vectors math 
       combinators.short-circuit ;
IN: contains

! Is elt in seq?
: contains? ( seq elt -- ? ) '[ _ = ] count 0 > ; inline

<PRIVATE

! Take elt, convert it into a closure that checks for it
! and pushes the closure onto seq
: push-contains ( seq elt -- seq )
    '[ _ contains? ] over push ; inline

! Takes a sequence and generates a vector of closures, one
! for each element, that checks for that elt in a given seq
: seq>contain-seq ( seq -- seq ) V{ } clone 
                              [ push-contains ]
                              reduce ; inline
PRIVATE>

! Does seq contain any of the elements of elts
: contains-any? ( seq elts -- ? ) seq>contain-seq 1|| ; inline

-----------------------------------

Everything works except for contains-any? which gives me a "Cannot apply
“1||” to a run-time computed value" error.

If I just put the contents of contains-any? directly into the listener
it works fine, but if it's compiled into a word, then it doesn't.

Reading the documentation of "call" it says that if it is run on inputs,
the function is inline, but even when I make all of the words inline (as
I have above), it still doesn't work.

I'm less interested in getting this particular piece of code working
than I am in understanding how to use inline, ||, and call correctly.

Thanks,

Matt Edlefsen


------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to