Martin T writes:
>..or for example, in Bash I could do "for i in $(seq $x); do echo -n =; done; 
>echo". What is the most elegant way to do this in SLAX? At the moment I solved 
>it with this:

You can brute force it with a loop or a recursive function (below),
but best to use the exslt extension function "str:padding":

    var $x = str:padding(168, "=");

FWIW, the brute force patterns are:

    var $x = {
        for-each (1 ... $count) {
            expr $char;
        }
    }

    var $x = call padding($char, $count);

where:

template padding ($char = " ", $count = 0) {
    if ($count > 0) {
        expr $char;
        call padding($char, $count = $count - 1);
    }
}

Running these with the profiler should easily convince you that the
extension function is the best answer.  Just showing the others for
educational purposes.  And because the conference call I'm on is
rather dull.

Thanks,
 Phil
_______________________________________________
juniper-nsp mailing list [email protected]
https://puck.nether.net/mailman/listinfo/juniper-nsp

Reply via email to