[plt-scheme] PLoT and histograms
On Jul 31, Paulo Jorge de Oliveira Cantante de Matos wrote:
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Indeed, you're right.
> So, here's my attempt at it:
> ;; Defining a new plot type to plot the frequency bars
> (define-plot-type histogram points 2dplotview
> () ((color 'red) (width 5))
>
> (send* 2dplotview
> (set-line-color color)
> (set-line-width width))
>
> (for-each
> (lambda (pts)
> (let [(vec-x (vector-ref pts 0))]
> (send 2dplotview plot-line (list (vector vec-x 0) pts))))
> points))
>
> Which fails with the not so specific message:
> define-plot-type: bad syntax in: (define-plot-type histogram
> points 2dplotview () ((color (quote red)) (width 5)) (send*
> 2dplotview (set-line-color color) (set-line-width width))
> (for-each (lambda (pts) (let ((vec-x (vector-ref pts 0))) (send
> 2dplotview plot-line (list (vector vec-x 0) pts)))) points))
>
>
> Any ideas why there's a problem with the above? If I remove the
> for-each everything works ok but I can't see a problem with it.
The reason this doesn't work is because there is no implicit 'begin'
in define-plot-type.
There is no implicit begin because 'define-plot-type' has two
different forms, and the macro could not easily disambiguate between
them if any number of body expressions were allowed.
--
-Alex