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

[REBOL] Re: Problems with block of datatype!s

From: holger:rebol at: 12-Sep-2001 10:55

On Wed, Sep 12, 2001 at 09:40:34AM -0800, Tim Johnson wrote:
> I would like to be able to test a word for a > match in a block whose members are datatypes. > > The example code doesn't do what I want it to do: > >> types: [string! number!] > == [string! number!] > >> find types string! > == none ; was hoping for [string! number!] > >> types/1 = string! > == false ; was hoping for 'true > Just curious: what else do I need to do here?
Change types: [string! number!] to types: reduce [string! number!] The reason is: In your block, "string!" is an unevaluated word (type word!), but in your call to 'find "string!" gets evaluated and becomes the datatype! "string!". Words are different from datatypes, so no match is found. Reducing the block evaluates the words in it and converts them to datatypes, allowing 'find to do what it should. This is not a bug btw. -- Holger Kruse [holger--rebol--com]