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

[REBOL] Re: Puzzle with FIND and SELECT

From: lmecir:mbox:vol:cz at: 11-Feb-2003 10:52

Hi all, as Joel showed, FIND uses a different comparing method than SAME? or EQUAL?. Here is a definition of an (almost)equivalence compatible with FIND: find-equivalent?: function [ {are A and B equivalent for FIND?} a [any-type!] b [any-type!] ] [block] [ block: make block! 2 insert/only block get/any 'a insert/only tail block get/any 'b equal? index? find block get/any 'b 1 ] As expected, we get: find-equivalent? 3 3.0 ; == false I call this an (almost) equivalence, because FIND crashes Rebol like e.g.: a: [] insert/only a a b: [] insert/only b b find-equivalent? a b CRASH! Moreover, this isn't the only equivalence FIND can generate. FIND/CASE generates a different equivalence, which more closely resembles the == function. Regards -L