Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!purdue!decwrl!hplabs!hp-ses!hpcuhb!hpcllla!hpclisp!hpclcdb!cdb From: cdb@hpclcdb.HP.COM (Carl Burch) Newsgroups: comp.lang.pascal Subject: C Ternary Conditional Expression? Message-ID: <950025@hpclcdb.HP.COM> Date: 23 May 89 20:35:52 GMT Organization: Hewlett-Packard Calif. Language Lab Lines: 26 Can anyone think of a way to express in Pascal a form equivalent to the ternary conditional expression in C without using a separate statement? I need to speed up an expression that usually matches a cached value, but can't figure out how to move the code out of the called function ( represented by f(indx) below) to save the procedure call overhead. For instance, how could one translate : a[ (indx == last_indx) ? last_val : f(indx) ] = a [ y ]; without using an IF statement? Preferably without using a temporary variable. The only Pascal equivalent I've generated is : IF (indx = last_indx) THEN temp := last_val ELSE temp := f(indx); a[temp] := a[y]; Please omit all flames - I just happen to know how to do this in C and nobody I've asked has been able to design a Pascal equivalent. Thanks, Carl Burch