Hi Alex
I'm really pleased I asked. Thank you for putting me straight.
Best Regards
Dean

On 12 January 2017 at 16:28, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > Is this the best way of automatically generating a list of ("aaaa" "bbbb"
> > etc.
>
> No ;)
>
>
> > (de mk_Ltest_data (Start_x Eles Ele_chars)
> >    (setq L (range Start_x (- (+ Start_x Eles) 1)))
> >    (setq L2 (mapcar 'char L))
> >    (setq L3 NIL)
> >    (for X (range 1 Ele_chars)
> >       (setq L3 (append L3 L2)) )
> >    (setq L4 (sort L3))
> >    (setq L5 (by name group L4))
> >    (setq L6 (mapcar 'pack L5)) )
>
> -- The variables 'L', 'L2' etc are not bound locally. 'lint' complains:
>
>    : (lint 'mk_Ltest_data)
>    -> ((bnd L6 L4 L3 L2 L) (use X))
>
> -- 'char' should not be quoted for the 'mapcar'.
>
> -- (for X (range 1 Ele_chars) ..) would be  (do Ele_chars ..)
>    In general I would not use 'range' just to get a loop.
>    Better  (for X Start_x ...  but only if 'X' is really needed.
>
> -- You are doing excessive 'setq's. Normal PicoLisp programs
>    almost never use 'setq'.
>
>
> I would write the above function as:
>
>    (de mk_Ltest_data (Start_x Eles Ele_chars)
>       (make
>          (do Eles
>             (link
>                (pack (need Ele_chars (char Start_x))) )
>             (inc 'Start_x) ) ) )
>
>    (msg (mk_Ltest_data 97 26 4))
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to