Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site harvard.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!sasaki From: sasaki@harvard.ARPA (Marty Sasaki) Newsgroups: net.lang.c Subject: Re: places where sets are useful Message-ID: <426@harvard.ARPA> Date: Tue, 5-Mar-85 23:09:30 EST Article-I.D.: harvard.426 Posted: Tue Mar 5 23:09:30 1985 Date-Received: Mon, 11-Mar-85 10:58:49 EST References: <10983@watmath.UUCP> <21000020@uiucuxc.UUCP> Organization: Aiken Computation Laboratory, Harvard Lines: 22 I use sets in two places, in recursive decent parsers, and in my chess playing program. If sets were implemented in C, then certain optimizations could be done by the compiler. Of couse, both places require more bits than provided in a long, but both of the Pascal compilers that I use allow at least 64 items in a set (DEC's Pascal for VMS, and Oregon Software's compiler for PDP-11's). The chess program represents chess boards as a set of 64 squares. By doing set operations on these "bitboards" one can generate moves, check for attacking pieces, evaluate pawn structure, etc. These operations can be done very fast. The recursive decent parser uses sets for error recovery. When a procedure which deals with a non-terminal is called, it is passed the set of symbols in the follow set for the non-terminal. If an error occurs, symbols are skipped until a symbol in the input stream is found that is in the follow set. The procedure is then returns. -- Marty Sasaki Havard University Science Center sasaki@harvard.{arpa,uucp} 617-495-1270