On Dec. 1, 2008, Adam Majewski wrote:
> (%i8) Plot2DDiscrete(x,xMin,xMax):=
> block(
> xx:makelist(i,i,xMin,xMax),
> yy:map(f,xx),
> load(draw),
> draw2d(
> point_type = filled_circle,
> point_size = 3,
> points_joined = false,
> color = blue,
> key = "punkty",
> points(xx,yy),
> terminal = 'screen)
>
>
> )$(%i9) Plot2DDiscrete(x,1,10);(%o9) [gr2d(points)]
>
>
> This function draws discrete points (x,y:f(x)),
>
> How to pass external function thru parameters ?
> ( here f is global function )
>
Why not use a Maxima "expression" with your listplot rather
than a Maxima "function"?
For example, the following listplot1 accepts either an
expression or a (official) Maxima function:
(%i1) display2d:false$
/* load draw once, not every time you
run listplot */
(%i2) load(draw)$
/* here is a version close to yours in
spirit */
(%i3) listplot1(expr,var,v1,v2):=
block([xx,f,yy,i],
xx:makelist(i,i,v1,v2),
define(f(var),expr),
yy:map(f,xx),
draw2d(
point_type = filled_circle,
point_size = 2,
points_joined = false,
color = blue,
key = "pts",
points(xx,yy),
terminal = 'screen) )$
/* here we use listplot1 with a Maxima
expression: */
(%i4) listplot1(x^3,x,0,10)$
/* here we use listplot1 with a Maxima
function */
(%i5) g(x):= x*sin(x)$
(%i6) listplot1(g(y),y,0,10)$
Ted Woollett