lemon-project-template-glpk

diff deps/glpk/examples/cal.mod @ 9:33de93886c88

Import GLPK 4.47
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 20:59:10 +0100
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/deps/glpk/examples/cal.mod	Sun Nov 06 20:59:10 2011 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +/* cal.mod - print an ASCII calendar of the given year */
     1.5 +
     1.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
     1.7 +
     1.8 +param year, integer, >= 0001, <= 3999, default 2010;
     1.9 +
    1.10 +param first_day{m in 1..12}, integer, >= 0, <= 6, :=
    1.11 +      time2str(str2time(year & "-" & m & "-01", "%Y-%m-%d"), "%w");
    1.12 +
    1.13 +param days_in_month{m in 1..12}, integer, >= 28, <= 31, :=
    1.14 +      (str2time(year + (if m < 12 then 0 else 1) & "-" &
    1.15 +         (if m < 12 then m+1 else 1) & "-01", "%Y-%m-%d") -
    1.16 +      str2time(year & "-" & m & "-01", "%Y-%m-%d")) / 86400;
    1.17 +
    1.18 +param foo{m in 1..12, k in 0..5, d in 0..6}, integer, :=
    1.19 +      7 * k + d + 1 - first_day[m];
    1.20 +
    1.21 +param cal{m in 1..12, k in 0..5, d in 0..6}, integer, :=
    1.22 +      if 1 <= foo[m,k,d] and foo[m,k,d] <= days_in_month[m] then
    1.23 +         foo[m,k,d];
    1.24 +
    1.25 +printf "\n";
    1.26 +printf "%33s%04d\n", "", year;
    1.27 +printf "\n";
    1.28 +for {t in 1..12 by 3}
    1.29 +{     for {m in t..t+2}
    1.30 +      {  printf "%7s%-14s", "", time2str(str2time(m, "%m"), "%B");
    1.31 +         printf{0..0: m < t+2} "   ";
    1.32 +      }
    1.33 +      printf "\n";
    1.34 +      for {m in t..t+2}
    1.35 +      {  printf "  S  M Tu  W Th  F  S";
    1.36 +         printf{0..0: m < t+2} "   ";
    1.37 +      }
    1.38 +      printf "\n";
    1.39 +      for {k in 0..5}
    1.40 +      {  for {m in t..t+2}
    1.41 +         {  for {d in 0..6}
    1.42 +            {  printf{0..0: cal[m,k,d]  = 0} "   ";
    1.43 +               printf{0..0: cal[m,k,d] != 0} " %2d", cal[m,k,d];
    1.44 +            }
    1.45 +            printf{0..0: m < t+2} "   ";
    1.46 +         }
    1.47 +         printf "\n";
    1.48 +      }
    1.49 +}
    1.50 +printf "\n";
    1.51 +
    1.52 +end;