🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.pascal
Article #325

Re: Linear search again

#325
From: Ben Cranston
Date: Sat, 09 Aug 1986 00:56
20 lines
1492 bytes
In article <2785@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:

>	find: PROC [ch: CHAR, string: LONG STRING]
>		RETURNS [pos: CARDINAL, found: BOOL];
>	BEGIN
>	    FOR i:CARDINAL in [0..String.Length[string]] DO
>		IF string[i] = ch THEN RETURN [i, TRUE];
>	    ENDLOOP;
>	    RETURN [0, FALSE];
>	END;

I always avoided these nonstandard returns because they make it painful to
drop in debug print statements.  I would always slap in WRITELN(MYARGS) at
the top, and WRITELN('Returning from FIND') at the bottom, and wonder why
I never saw the 'Returning from FIND' output...  If you are trying to find
an infinite loop this can be really misleading.
-- 
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"
Technical Details
Message-ID: <1174@umd5>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!lll-crg!seismo!umcp-cs!cvl!umd5!zben
References: <871@minster.UUCP> <2785@umcp-cs.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!lll-crg!seismo!umcp-cs!cvl!umd5!zben
From: zben@umd5 (Ben Cranston)
Newsgroups: net.lang.pascal
Subject: Re: Linear search again
Message-ID: <1174@umd5>
Date: Fri, 8-Aug-86 20:56:21 EDT
Article-I.D.: umd5.1174
Posted: Fri Aug  8 20:56:21 1986
Date-Received: Sun, 10-Aug-86 20:07:13 EDT
References: <871@minster.UUCP> <2785@umcp-cs.UUCP>
Reply-To: zben@umd5.umd.edu (Ben Cranston)
Organization: University of Maryland, College Park
Lines: 20
Summary: Nonstandard RETURNs considered constraining