Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!cit-vax!wen-king From: wen-king@cit-vax.Caltech.Edu (King Su) Newsgroups: comp.lang.c Subject: powerful expressions Message-ID: <12855@cit-vax.Caltech.Edu> Date: 2 Dec 89 06:14:29 GMT Organization: California Institute of Technology Lines: 30 References Sender: Reply-To: wen-king@cit-vax.UUCP (Wen-King Su) Followup-To: Distribution: Organization: California Institute of Technology Keywords: While we are discussing styles, let's talk about simple expressions that do a lot things. struct QUEUE { struct QUEUE *next; <... other fields in the structure ...> } ; struct QUEUE *qhead, *qtail, *qnew; I have concocted the following single expression that appends 'qnew' to the queue formed by 'qhead' and 'qtail'. The queue is null terminated, 'qhead' points to the first element of the queue, and 'qtail' points to the last element of the queue: ((qhead) ? (qtail = qtail->next = qnew) : (qtail = qhead = qnew))->next = 0; Do you have any favorite C-expressions that you would like to share? -- /*------------------------------------------------------------------------*\ | Wen-King Su wen-king@vlsi.caltech.edu Caltech Corp of Cosmic Engineers | \*------------------------------------------------------------------------*/