hi kai
you might want to copy the block and use remove-each, its a very fast
iterator, and expressly built for filtering.
remove-each 'item copy ["a" 1 2 4 "f"] [integer? item]
== ["a" "f"]
using any or all in the evaluated block, is a very dense way to do
multi-rule filtering
remove-each 'item copy ["a" 1 2 4 "f"] [
any [
all [integer? item item > 3]
all [string? item find item "a"]
]
]
== [1 2 "f"]
also, just adding a 'NOT in front of the 'ANY, reverses the filter, which is
handy if you want to split the same incongruous data set into two pieces.
-MAx
On Nov 29, 2007 11:14 PM, Kai Peters <[EMAIL PROTECTED]> wrote:
>
> Does anyone have suggestions on how to improve the function below?
>
> TIA,
> Kai
>
> The 'filter function below returns a result block containing only
> "records"=
> having
> the filter criterion crit in "column" column
>
>
>
> filter: function [ cursor [block!] reclen [integer!] column [integer!]
> crit=
> ] [ rec result tmp ] [
> ;
> result: make block! length? cursor
> crit: to-string crit
> ;
> forskip cursor reclen [
> rec: copy/part cursor reclen
> ;
> if none <> find to-string cursor/:column crit [ insert tail result
> rec=
> ]
> ]
> result
> ]
>
> s: s: [ 100 "Jim" 45
> 201 "Bob" 52
> 325 "Will" 16 ]
>
> probe filter s 3 2 "i" ; filter for names containing letter "i"
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>
>
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.