Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Antwort: Re: Antwort: Switch! (LONG)

From: brett:codeconscious at: 21-Nov-2000 23:02

> You said "Yell", well I´m yelling!
:)
> result-block: make block! (multiply 2 length? index-block) > could you tell me why you initialized the block in this form?
Only that I believe it pre-allocates memory for the new block to that size. Everything between ( and ) just calculates how many elements I expect in the final block. It is purely a performance tweak.
> I´ve noticed > that you pass references to blocks and words by copying, e.g > newblock: copy [] > does it have an advantage over > newblock: make block! 0 ?
It is shorter. :) And I'm a little nervous about passing in 0 as an argument to the make function (programmers superstition?). Other than that it is exactly the same. If I didn't use copy I would end up changing my code - so all I'm doing is creating a new empty block that is a copy of an existing empty block. Brett.
> foreach [char file-list] index-some-data read %. [ > write-my-page char file-list > ] > I presume you "read" the directory in "index-some-data" but without the > colon? I expected something like this > foreach [char file-list] index-some-data: read %. [ > write-my-page char file-list > ]
Nope. index-some-data was a function I defined in my post. It takes a block as an argument. "read %." produces a block as a result. So all I'm doing is passing the list of files to my function index-some-data which it will then chew on for a bit. When it finishes it will return a block that the foreach will chew on for a bit.
> That means I just have to parse the <title> tag contents of all the files > in a given directory and pass it as "some-pagerefs" items ?
Hmm. Well if you did you would certainly get a page generated but the hrefs would not be valid. I didn't actually cater for the titles and the corresponding files - sorry. I'll have a quick look and probably post something in a little while that does. ____________________________________________________________________________ ___________
> This is one of the parts that I like best > "either indexed-item: find index-block first item [" > I never thought that the left to right evaluation in REBOL could also be > passed as a expression to "either" or "for"
It gets better. Either and for return values too - the last value in their blocks.
>> print either [equal? 1 1] ["yep"]["nup"]
yep