[metapost] Unable to figure out "if"

Hartmut Henkel hartmut_henkel at gmx.de
Thu Aug 9 20:32:45 CEST 2012


On Wed, 8 Aug 2012, Karel wrote:

> logical statements should be separated and the value of numeric anta
> cannot be changed by another equality. The following works:
>
> beginfig ( 1 ) ;
>  for i = -60 step 10 until 61 : anta:=
>  	if (i > -31) and (i < 31) : 70 ;
>  	else : 60 ;
> 	fi ;
> 	draw ( -anta, i ) -- ( anta, i ) ;
>  	draw ( i, -anta ) -- ( i, anta ) ;
>  endfor ;
>  endfig ;
>  end ;

...maybe it should be mentioned here, that any spaces after (, before ),
before :, and before ; are not necessary (and imho bloat the code). MP
may be cryptic at times, but it's at least more forgiving than a bourne
shell :-)

Regards, Hartmut



More information about the metapost mailing list