[REBOL] Re: Formatting a display line
From: joel:neely:fedex at: 4-Nov-2003 17:04
Hi, Steven,
The typing of the parameter has already been pointed out, but
let me give you a speed improvement as well.
Using SOURCE shows us that APPEND is essentially INSERT TAIL
(just what you'd expect), and INSERT has a /DUP refinement that
duplicates the insertion, so instead of ...
Steven White wrote:
> ADD-FILLER: func [
> "Add a specified number of blanks to FORMATTED-LINE"
> SPACE-COUNT integer!
> ] [
> PRINT ["NOW WE WILL ADD " SPACE-COUNT " SPACES"]
> loop SPACE-COUNT [
> append FORMATTED-LINE " " ;; 4444
> PRINT ["FORMATTED LINE IS " LENGTH? FORMATTED-LINE "
> BYTES:" FORMATTED-LINE]
> ]
> ]
>
... just define ...
add-filler: func [
"add specified number of spaces to formatted-line"
space-count [integer!]
][
insert/dup tail formatted-line " " space-count
]
--
----------------------------------------------------------------------
Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446
Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1