Plotting a polygon
- To: mathgroup at yoda.physics.unc.edu
- Subject: Plotting a polygon
- From: koleh%joyl.dnet at joyx.joensuu.fi
- Date: Fri, 11 Dec 1992 14:42:20 +0300
Hi Mathgroup ! What is the problem here? My student tried to plot a polygon in a complicated way. Mathematica 2.0 for MS-DOS 386/7 Copyright 1988-91 Wolfram Research, Inc. In[1]:= t=Table[Random[],{5},{2}]; This works: In[2]:= Show[Graphics[Map[Line,Partition[AppendTo[t,First[t]],2,1]]]] Out[2]= -Graphics- But when he uses a function polygon[], it does not work. In[3]:= polygon[t_]:= Show[Graphics[Map[Line,Partition[AppendTo[t,First[t]],2,1]]]] In[4]:= polygon[t] AppendTo::rvalue: {{0.10459, 0.840989}, {0.177361, 0.503785}, <<3>>, {0.10459, 0.840989}} has not been assigned a value. AppendTo::argr: AppendTo called with 1 argument; 2 arguments are expected. AppendTo::argr: AppendTo called with 1 argument; 2 arguments are expected. Graphics::gprim: Unknown Graphics primitive AppendTo[Line[AppendTo[<<2>>]]] encountered. Out[4]= -Graphics- In[5]:= ?polygon Global`polygon polygon[t_] := Show[Graphics[Line /@ Partition[AppendTo[t, First[t]], 2, 1]]] Osmo Kolemainen University of Joensuu Finland