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

[REBOL] Re: Correct Behaviour? Was False = 2 ????

From: lmecir:mbox:vol:cz at: 5-Jul-2001 11:02

Hi, 1) there is no need to change AT to 0-based, because we have got SKIP 2) based?: func [ f [any-function!] block [block!] i [integer!] ] [ (index? block) + i - (index? f block i) ] a: skip [-1 0 1 2] 2 ; == [1 2] based? :at a 1 ; == 1 based? :at a 2 ; == 1 based? :skip a 0 ; == 0 based? :skip a 1 ; == 0 based? :at a 0 ; == 0 based? :at a -1 ; == 0 based? :at a -2 ; == 0 based? :skip a 0 ; == 0 based? :skip a -1 ; == 0 ==> AT is implemented inconsistently, because it is neither 1-based, nor 0-based! 3) if I look at the functions: FIRST, SECOND, ..., I found their behaviour natural 4) PICK looks OK as a generalization of the FIRST, SECOND, ... for 1<= index <= length? block 5) PICK is neither 1-based, nor 0-based (It is worse than AT, because it's got an "Emental Property" - see a "hole" at zero!). ==> Inconsistent. 6) PICK is "Too Consistent" for me in this case: pick [none] 1 ; == none pick [none] 2 ; == none 7) the following behaviour is inconsistent from the zero-based POV as well as from one-based POV: a: [1] remove a b: skip a 1 index? b ; == 1 while: a: [1] b: skip a 1 remove a index? b ** Script Error: Out of range or past end ** Where: halt-view ** Near: index? b There are two ways how to get a different behaviour here: 7a) define: skipped?: func [ block [block!] ] [ if error? try [return (index? block) - 1] [ (index? tail block) - 1 ] ] a: [1] b: skip a 1 remove a skipped? b ; == 0 7b) define a JUMP and JUMPED? functions having this property: a: [1] b: jump a 1 ; == [] jumped? b ; == 1 remove a jumped? b ; == 1 a: [1] remove a b: jump a 1 jumped? b ; == 1 This would have a capability of allowing any-base indexing, my Rebol Brothers. Howgh