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

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

From: robbo1mark:aol at: 6-Jul-2001 10:59

JOEL, Why can't you simply undertsand that your menatl model ( & mine 8) is a MUTILATION of REBOL. Arithmetic is GOOD for you, it expands the mind. cheers, Mark Dickson In a message dated Fri, 6 Jul 2001 10:44:42 AM Eastern Daylight Time, Joel Neely <[joel--neely--fedex--com]> writes: << Hi, Robert, Robert Lancaster wrote:
> Forgive me if I'm on the wrong thread for this observation.. > but some people have used an example > > Number of children in a house hold. > > 0: 3 > 1: 5 > 2: 6 > 3: 1 > 4: 4 > > As an example of zero based indexing. >
Well, sort of... I offered it as an example of a situation where the natural sequence of values (call them "categories" if you wish) runs from 0 upwards, rather than from 1 upwards. Since it had been implied that such a situation would never occur to normal people (systems programmers and academics not being normal ;-), I thought I'd offer a normal-looking example.
> It may be easy to program it into a zero based index. But > the storage method does not reflect on the information the > data represents. >
You're absolutely correct. However, when our programming language allows us to express directly what we're dealing with in the problem domain, that's a very nice situation. As a concrete example (see the thread on "byte frequencies" for another), let's assume we have a block with trivial census data similar to the above example, and write some code to calculate the stats. census: [ "PM" 1 "HD" 0 "SE" 0 "SK" 3 "JV" 2 "AT" 3 "NJ" 2 "JD" 4 "TC" 1 "KK" 1 ] tally: func [ndeps [block!] /local tots] [ tots: array/initial 5 0 foreach [who kids] ndeps [ poke tots 1 + kids 1 + pick tots 1 + kids ] repeat ikids length? tots [ print rejoin [ikids - 1 ":" tab pick tots ikids] ] ] which performs
>> tally census
0: 2 1: 3 2: 2 3: 2 4: 1 My "mental model" of this tally is a collection of buckets labeled 0..4, but the code is sprinkled with "+ 1" and "- 1" because I can't use that model directly. -jn- ___________________________________________________________________ The purpose of computing is insight, not numbers! - R. W. Hamming joel'dot'neely'at'fedex'dot'com