[REBOL] Re: curious use of LENGTH?
From: lmecir:mbox:vol:cz at: 31-Jan-2002 15:32
Hi Joel,
even
while [((length? s) // max) <> 0] [append s " "]
looks unusual to me. I normally use:
insert/dup tail s " " max - ((length? s) // max)
Cheers
Ladislav
----- Original Message -----
From: "Joel Neely" <[joel--neely--fedex--com]>
To: <[rebol-list--rebol--com]>
Sent: Thursday, January 31, 2002 2:16 PM
Subject: [REBOL] curious use of LENGTH?
I happened to do SOURCE LIST-DIR this morning, and something caught
my eye; at the end of that function is the following excerpt:
...
s: make string! 0
foreach file dir [
append s file
while [((length? s) // max) <> 0] [append s " "]
if (length? s) > 60 [
print s
clear s
]
]
if length? s [print s]
]
I only included so much to get all uses of S (local to LIST-DIR).
Notice the last line -- I have no clue what it means in REBOL to
use an integer-valued expression as the condition of IF. I tried
some small experiments, and in every case IF treated an integer
as TRUE (including zero and negative values). I then tried
variations on a string value FOO in the phrase IF LENGTH? FOO ...
and always got the equivalent of TRUE, regardless of its length.
(The only exception was when FOO was UNSET, in which case I got
an error...)
Any suggestions on why the above wasn't written simply as
PRINT S
?? Clearly it's there to flush a partial line at the end of
grovelling through the list of file names, but why in the form
shown by SOURCE above?
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;