RE: Adding scoped local set/param declaration to GMPL

2020-08-25 Thread Meketon, Marc
On a more serious note...

I don’t think local set/param declaration is that useful.  In the example 
given, you could create a one-dimensional array of sets and params that does 
the same thing.

-Marc

-Original Message-
From: Help-glpk  On 
Behalf Of Andrew Makhorin
Sent: Tuesday, August 25, 2020 5:03 PM
To: Domingo Alvarez Duarte ; help-glpk@gnu.org
Subject: Re: Adding scoped local set/param declaration to GMPL

On Tue, 2020-08-25 at 22:12 +0200, Domingo Alvarez Duarte wrote:
> Hello !
>
> I'm experimenting with allow local set/param declarations inside
> scoped blocks (for/if/then/else), it's the base to possibly experiment
> further with problem/callback/function declarations you can
> see/experiment with it in this branch
> https://github.com/mingodad/GLPK/tree/local-set-para
> m
> , look at
> https://github.com/mingodad/GLPK/blob/local-set-param/examples/shikaku
> -if.mod
> and
> https://github.com/mingodad/GLPK/blob/local-set-param/examples/test-if
> .mod
> to see it's usage.
>
> 
>
> for{i in 1..4} {
>  printf "now we are at %d\n", i;
>  if i mod 2 = 0 then { #assert when missing "= 0"
>  param lp := i+10;
>  set ls := {1..i+1};
>  printf "nested if lp = %d\n", lp;
>  display ls;
>  }
>  param lp := i+20;
>  set ls := {1..i+2};
>  printf "nested for lp = %d\n", lp;
>  display ls;
> }
>
> 
>
> Any comment/suggestion is welcome !
>
> Cheers !
>
>
>

I guess the next step will be implementation of classes? ;)




This e-mail and any attachments may be confidential or legally privileged. If 
you received this message in error or are not the intended recipient, you 
should destroy the e-mail message and any attachments or copies, and you are 
prohibited from retaining, distributing, disclosing or using any information 
contained herein. Please inform us of the erroneous delivery by return e-mail. 
Thank you for your cooperation.


Re: Adding scoped local set/param declaration to GMPL

2020-08-25 Thread Andrew Makhorin
On Tue, 2020-08-25 at 22:12 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> I'm experimenting with allow local set/param declarations inside
> scoped 
> blocks (for/if/then/else), it's the base to possibly experiment
> further 
> with problem/callback/function declarations you can see/experiment
> with 
> it in this branch https://github.com/mingodad/GLPK/tree/local-set-para
> m 
> , look at 
> https://github.com/mingodad/GLPK/blob/local-set-param/examples/shikaku
> -if.mod 
> and 
> https://github.com/mingodad/GLPK/blob/local-set-param/examples/test-if
> .mod 
> to see it's usage.
> 
> 
> 
> for{i in 1..4} {
>  printf "now we are at %d\n", i;
>  if i mod 2 = 0 then { #assert when missing "= 0"
>  param lp := i+10;
>  set ls := {1..i+1};
>  printf "nested if lp = %d\n", lp;
>  display ls;
>  }
>  param lp := i+20;
>  set ls := {1..i+2};
>  printf "nested for lp = %d\n", lp;
>  display ls;
> }
> 
> 
> 
> Any comment/suggestion is welcome !
> 
> Cheers !
> 
> 
> 

I guess the next step will be implementation of classes? ;)




Adding scoped local set/param declaration to GMPL

2020-08-25 Thread Domingo Alvarez Duarte

Hello !

I'm experimenting with allow local set/param declarations inside scoped 
blocks (for/if/then/else), it's the base to possibly experiment further 
with problem/callback/function declarations you can see/experiment with 
it in this branch https://github.com/mingodad/GLPK/tree/local-set-param 
, look at 
https://github.com/mingodad/GLPK/blob/local-set-param/examples/shikaku-if.mod 
and 
https://github.com/mingodad/GLPK/blob/local-set-param/examples/test-if.mod 
to see it's usage.




for{i in 1..4} {
    printf "now we are at %d\n", i;
    if i mod 2 = 0 then { #assert when missing "= 0"
    param lp := i+10;
    set ls := {1..i+1};
    printf "nested if lp = %d\n", lp;
    display ls;
    }
    param lp := i+20;
    set ls := {1..i+2};
    printf "nested for lp = %d\n", lp;
    display ls;
}



Any comment/suggestion is welcome !

Cheers !