🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5215

Re: 0-based/1-based arrays

#5215
From: Barry Margolin
Date: Fri, 04 Mar 1988 20:09
20 lines
1075 bytes
In article <35@goose.UUCP>  writes:
[First example elided]
>Walking with a stride of three looks like
>	0-based		       	    1-based
>        for (j = 0; j < n/3; j++)   for (j = 1; j <= n/3; j++)
>            frob( a[3*j]);             frob( a[3*(j-1)+1])
>In both cases the 0-based code looks more intuitive to me.

And neither looks as intuitive as:

for (j = {0,1}; j {<,<=} n; j = j+3)
    frob (a[j]);

does to me (where {X,Y} means to use X in 0-based and Y in 1-based).

Barry Margolin
Thinking Machines Corp.

barmar@think.com
uunet!think!barmar
Technical Details
Message-ID: <17522@think.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!necntc!ima!think!barmar
References: <7161@sol.ARPA> <2740@mmintl.UUCP> <4343@june.cs.washington.edu> <35@goose.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!necntc!ima!think!barmar
From: barmar@think.COM (Barry Margolin)
Newsgroups: comp.lang.misc
Subject: Re: 0-based/1-based arrays
Message-ID: <17522@think.UUCP>
Date: 4 Mar 88 20:09:58 GMT
References: <7161@sol.ARPA> <2740@mmintl.UUCP> <4343@june.cs.washington.edu> <35@goose.UUCP>
Sender: usenet@think.UUCP
Reply-To: barmar@fafnir.think.com.UUCP (Barry Margolin)
Organization: Thinking Machines Corporation, Cambridge, MA
Lines: 20
Keywords: 0-based for me