Path: utzoo!attcan!uunet!ginosko!gem.mps.ohio-state.edu!csd4.csd.uwm.edu!bionet!ig!arizona!gudeman From: gudeman@arizona.edu (David Gudeman) Newsgroups: comp.lang.misc Subject: Re: What I'd really like to see in an if-statement... Message-ID: <13299@megaron.arizona.edu> Date: 17 Aug 89 23:13:12 GMT Organization: U of Arizona CS Dept, Tucson Lines: 27 In article <1989Aug14.022903.22953@agate.berkeley.edu> mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) writes: [summary: in Icon, (1) a relational operator "fails" if the relation does not hold, and produces the value of the right operand if the relation holds. (2) if one argument to an operation fails, the whole operation fails. (3) conditional contexts like "ifthen" and "while do" use failure as false, and any value as "true".] > > if a < b < c < d then > >Will work as you'd expect - succeeding only if all the comparisons are >true. Likewise for: > > if a < b <= c = d < e then This mechanism has much more far-reaching consequences that just allowing relational operators to "cascade" properly. Here are a couple of other Icon expressions: i := (i < j) # assign j to i only if i is less than j # the | symbol returns the results of both operands, one at a time if f(i) < (j | k) then ... # if result of f(i) is less than j or k then ... -- David Gudeman Department of Computer Science The University of Arizona gudeman@arizona.edu Tucson, AZ 85721 {allegra,cmcl2,ihnp4,noao}!arizona!gudeman