[REBOL] Re: Find/deep
From: ryanc:iesco-dms at: 20-Apr-2001 13:46
> Hi all,
> I was wondering if anyone has a function that will do a find/deep
> on arrays.
> arrays such as [["AA"] [["B"]["C"]] ["DD"]].
Once again I dig into my chainsaw collection. While not as multipurpose
as 'find, this sucker will tell you if its in there.
deep-find: func [
"Searches for a particular element in a block, recursing sub-blocks."
haystack [block!] "Block to search."
needle [any-type!] "Element to search for."
foreach thing haystack [
if thing = needle [ return true] ; Ouch!
if all [ block? thing deep-find thing needle ] [ return true] ; Found
return false ; Not here!