GreycLab / gmic

GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing
Other
66 stars 11 forks source link

Suggestion, allow multiple arguments in place of arg... convention in math parser. #14

Closed Reptorian1125 closed 7 months ago

Reptorian1125 commented 11 months ago

I think G'MIC should detect whether the last one is using arg... or not instead of having it as the only argument. To explain, here's a code:

Current implementation

foo:

status {"
  generate_random_numbers_with_exclusion(input...)=(
    ref([input],v_inp);
    s_in=size(v_inp);
    if(s_in<=3,run('error inv_inp'););
    number_of_exclusion=s_in-2;
    si=v_inp[0]; # start_index
    ei=v_inp[1]; # start_end
    do(
      rn=int(u(si,ei,1,0));
      for(p=2,p<s_in,++p,
      if(rn<v_inp[p],break(););
      ++rn;
     );
    ,rn>=ei);
  rn;
 );
 generate_random_numbers_with_exclusion($*);
 "}

With suggestion

foo:

status {"
  generate_random_numbers_with_exclusion(start_index,end_index,arg...)=(
    ref([arg],v_inp);
    do(
      rn=int(u(start_index,end_index,1,0));
      repeat(size(v_inp),p,
        if(rn<v_inp[p],break(););
        ++rn;
      );
    ,rn>=end_index);
    rn;
  );
 generate_random_numbers_with_exclusion($*);
 "}

Which is easier to understand? The second one. And it's shorter, easier to format too.

dtschump commented 11 months ago

Not possible for the moment.