Hi, I try to get the following behaviour:

        test-action: [print "---" probe first iterator]
        test-predicate: [print type? list]

        forall-records object-list test-predicate test-action

        forall-records: func [list predicate action][
                do predicate ; just for simple test

                ; iterate through the whole list of values
                ; check if the first entry satisfies the predicate
                ; if so execute the action
                forall list [if predicate [action]]
        ]

I want to provide a predicate and an action that can use the parameters
and local words. Of course the above code fails

** Script Error: list has no value

What I came up with is a not so nice and IMO inflexible solution:

        forall-records: func [list predicate action][
                if any [none? list empty? action][exit]

                ; iterate through the whole list of values
                ; check if the first entry satisfies the predicate
                ; if so execute the action
                forall list [if (predicate first list) [do action]]
]

test-predicate: func [object][
        either not none? (select object 'name) [true][false]
]

forall-records object-list :test-predicate test-action

I expect the first problem to be a binding problem. I read through the
bindung stuff provided by Ladislaw but it's really hard... So how can
the concept of C++ iterators, predicates, and functionids be implemented
in Rebol? Did someone already wrote some generic functions for this?
Robert


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to