Thank you Alex.  My work with CL lately has clearly been rubbing off on
me.  I'll combat that with more picolisp thanks to your tip.  What a
wonderful language to work in.

-David


On Mon, Mar 3, 2014 at 2:45 AM, Alexander Burger <a...@software-lab.de>wrote:

> On Sun, Mar 02, 2014 at 05:38:20PM -0500, me wrote:
> > Please help point me in the right direction once again?  What I'm
> > attempting to achieve is something like:
> >
> > (<div> "progress"
> >                   (<div> '("progress-bar progress-bar-success"
> >                            (role . "progressbar")
> >                            (aria-valuenow . "-79")
> >                            (aria-valuemin . "-100")
> >                            (aria-valuemax . "100")
> >                            (style . "width: 79%") )
> >                      (<span> "sr-only" "79% Nominal") ) )
> >
> >
> > What I have is:
> >
> > (de make-progress-bar (bar-type width)
> >    (<div> "progress"
> >       (<div> '(`(,pack "progress-bar progess-bar-" ,bar-type)
> >                (role . "progressbar")
> >                (aria-valuenow . `(,pack ,width))
> >                (aria-valuemin . "-100")
> >                (aria-valuemax . "100")
> >                (style . `(,pack "width: " ,width "%")) )
> >          (<span> "sr-only" `(,pack ,width "% Nominal")) ) ) )
> >
> >
> > What is the idiomatic way to manipulate text such that I can dynamically
> > generate different types of progress bars?  The idea being that I could
> use
> > different color coded static progress bars as a simple form of charting
> > data.
>
> The problem with the solution above is that the backquote has a meaning
> in PicoLisp different from that in CL. It is a read macro, not a
> pattern-filler at runtime. Same goes for the comma.
>
> Passing a list dynamically at runtimes means that it must be built at
> runtime. This should work:
>
>    (de make-progress-bar (Bar-type Width)
>       (<div> "progress"
>          (<div>
>             (list
>                (pack "progress-bar progress-bar-" Bar-type)
>                '(role . "progressbar")
>                (cons 'aria-valuenow Width)
>                '(aria-valuemin . "-100")
>                '(aria-valuemax . "100")
>                (cons 'style (pack "width: " Width "%")) )
>             (<span> "sr-only" Width "% Nominal") ) ) )
>
>    (make-progress-bar "success" 79)
>
> You might also take a look at 'fill' (which is a bit similar to the CL
> backquote function) to build the list, but that's a little more
> involved in this case:
>
>    (de make-progress-bar (Bar-type @Width)
>       (let
>          (@B (pack "progress-bar progress-bar-" Bar-type)
>             @W (pack "width: " @Width "%") )
>          (<div> "progress"
>             (<div>
>                (fill
>                   '(@B
>                      (role . "progressbar")
>                      (aria-valuenow . @Width)
>                      (aria-valuemin . "-100")
>                      (aria-valuemax . "100")
>                      (style . @W) ) )
>                (<span> "sr-only" @Width "% Nominal") ) ) ) )
>
>    (make-progress-bar "success" 79)
>
> The effect is the same in both cases.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to