help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Help-glpk] Wish list - an extended "if then else" statement


From: Andrew Makhorin
Subject: RE: [Help-glpk] Wish list - an extended "if then else" statement
Date: Fri, 14 Jan 2011 15:07:27 +0300

On Sat, 2011-01-01 at 10:55 -0600, Meketon, Marc wrote:
> Cool!  Thank you!  A bit of a kludge, but a lot better than my kludge.
> 
> 
> -----Original Message-----
> From: glpk xypron [mailto:address@hidden
> Sent: Saturday, January 01, 2011 7:50 AM
> To: Meketon, Marc; address@hidden
> Subject: Re: [Help-glpk] Wish list - an extended "if then else" statement
> 
> Hello Marc,
> 
> > for{(time,ad) in EVENTS} {
> >   if ad='A' then printf "dual=%3g  %5d\n", ARRIVALS[time].dual, time
> >
> >   else printf "          %5d dual=%3g\n", time, DEPARTURES[time].dual;
> > }
> >
> > but that doesn't work.
> 
> This is the closest you can get with the existing syntax:
> 
> for{(time, ad) in EVENTS} {
>   printf{ i in {1} : ad == "A" }
>     "dual=%3g  %5d\n", ARRIVALS[time].dual, time;
>   printf{ i in {1} : ad != "A" }
>     "%5d dual=%3g\n", time, DEPARTURES[time].dual; }
> 
> Best regards
> 
> Xypron

Another, more general way to simulate the if-then-else statement

   if c then S1 else S2

is the following:

   for {0..0: c}
   {
      S1;
   }
   for {0..0: not c}
   {
      S2;
   }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]