Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site utcsrgv.UUCP
Path: utzoo!utcsrgv!mason
From: mason@utcsrgv.UUCP (Dave Mason)
Newsgroups: net.lang.apl,net.lang.c,net.lang.lisp,net.lang.pascal,net.lang.mod2,net.lang.prolog,net.lang.st80
Subject: Language Idioms
Message-ID: <764@utcsrgv.UUCP>
Date: Mon, 11-Feb-85 20:47:32 EST
Article-I.D.: utcsrgv.764
Posted: Mon Feb 11 20:47:32 1985
Date-Received: Mon, 11-Feb-85 22:30:35 EST
Distribution: net
Organization: University of Toronto/Ryerson Polytechnic Institute
Lines: 25

I am teaching a course on comparative programming languages, and one of the
things I wish to bring out is the different viewpoints offered by different
languages.  As an example of this I want to talk about programming idioms.
These are code sequences which produce some useful non-obvious result.  The
languages I am talking about are: PASCAL, SNOBOL4, APL, LISP, and C.  The
students' backgrounds are mostly PL/I and FORTRAN with a smattering of
COBOL.  I would appreciate any examples you know of in any of these
languages.  As an example here are some I know of:
	In APL (there are many) if you have a character array with keywords
		one per row (KEY) and a word you wish to check (WORD) you
		say:	(KEY =.and WORD) iota 1		and you get the
		keyword number.

	In C (I'm sure there are many) to copy a character string:
		while (*dest++ = *source++) /* do nothing */ ;

I'm sure there are lots in APL, C, LISP, maybe SNOBOL4, maybe even PASCAL.
I will post a summary (anonymous if you wish) if there is enough interest.
(Please mail responses, I unfortunately don't have time to read all groups)
-- 
Usenet:	{dalcs dciem garfield musocs qucis sask titan trigraph ubc-vision
 	 utzoo watmath allegra cornell decvax decwrl ihnp4 uw-beaver}
	!utcsrgv!mason		Dave Mason, U. Toronto CSRI
CSNET:	mason@Toronto
ARPA:	mason%Toronto@CSNet-Relay