Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Find/deep

From: ryanc:iesco-dms at: 20-Apr-2001 13:46

bill wrote:
> 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"]]. > Bill. >
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 it deep! ] return false ; Not here! ]