kill(all)$

maxima : draw square dived ( = disconnect points,between the lines),version 1.0
peter.vlasschaert@gmail.com,16/10/2020

load packages
============

load(draw)$

square ,lines
==========

example : How to write function in maxima and the connection with draw2d.

name_function(arguments ,.....) := block([local variables],
commands,......,......., return( output)
);

rem : no 'comma' before close   : ( a,b,c) not (a,b,c,)  → error

example :arguments be list : '[a,b,c]', single variables.
-------------------------------------------------------------------------

/* set defaults in draw2d */
set_draw_defaults(
  points_joined = true,
  point_size =0.5 , 
  point_type = circle,  /* point_type = dot */
  line_type = dashes, 
  proportional_axes = 'xy) $

/* build a grid */
squaredived(xmin,xmax,ymin,ymax,n) :=
  block([dx, dy],
    dx: (xmax-xmin)/n,
    dy: (ymax-ymin)/n,
    append(
       makelist(
          points(makelist([xmin+j*dx, ymin+k*dy],
                          k, 1, n)),
          j, 1, n),
       makelist(
          points(makelist([xmin+j*dx, ymin+k*dy],
                          j, 1, n)),
          k, 1, n)) )$
/* draw grid */
wxdraw2d(squaredived(-5,5,-5,5,20)) $

rem : combination function , inside draw2d.
rem : wx before draw2d inside the maxima document.

→ local variables.

dx;
dy;

structure of the code
----------------------------

n:5$
x0:-3$
x1:3$
y0:-3$
y1:3$

    dx: (x1-x0)/n$
    dy: (y1-y0)/n$ 
      /* vertical lines,red */   
       v1:makelist(
       points(makelist([x0+j*dx, y0+i*dy],
                          i, 1, n)),
          j, 1, n)$
       /* horizontal lines,blue */
       v2:makelist(
          points(makelist([x0+i*dx, y0+j*dy],
                          i, 1, n)),
          j, 1, n)$

→ global variables

dx;
dy;

v1;

v2a:float(v1);

wxdraw2d(line_type = solid,
    color = red,v1,color = blue,v2) $

a) suppose : list of numbers {k1,k2}
-------------------------------------------------

k1:[[1,2],[2,3],[3,4],[4,9]];
k2:[[5,7],[7,9],[10,4],[13,7]];

k:[k1,k2];

b)  how to get structure like v2a
--------------------------------------------

→ construct : 'error'
================

xx1:[sconcat(sconcat("points(",k1),")")];

xx1a:[xx1[1],xx1[1]];

/* wxdraw2d(xx1a),error   */

→ construct:'no error'
=================

xx2:makelist(points(k[i]),i,1,2);

wxdraw2d(color=black,xx2)$

wxdraw2d(point_size=1,color=red,xx2[1],
    color=blue,line_type=solid,xx2[2])$