Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: which is better?
Pages: [1] Print
Author Topic: which is better?  (Read 322 times)
fhein
Newbie
*
Offline Offline

Posts: 47


View Profile
which is better?
« on: May 12, 2005, 10:02:09 PM »

which one of the following is the better solution, and do they even produce the same result? Tongue

either any-block? data [
   append content rejoin data
][
   append content data
]


or:


append content to-string reduce data
Logged
CarlRead
Full Member
***
Offline Offline

Posts: 105


View Profile
which is better?
« Reply #1 on: May 13, 2005, 10:32:55 PM »

I'm pretty sure they'd return the same results.  As to which is better, well it depends on how you define better. :-)  The first version could be refactored though, giving you this...
Code:
append content either any-block? data [rejoin data][data]

Which is still longer than your other version, so it's just a case of which is faster, (probably little difference), or which you think is the more readable.  I'd go for your second version, as I suspect to-string does much the same thing as your any-block? check, just at native speed.
Logged

- Carl Read
Sunanda
Full Member
***
Offline Offline

Posts: 100


View Profile
which is better?
« Reply #2 on: May 21, 2005, 01:45:59 AM »

The first works with recursive blocks while the to-string option does not.

Try it with this data:

data: copy []
append/only data data
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: which is better?
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 30, 2008, 06:33:34 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2243 Posts in 587 Topics by 2010 Members
Latest Member: techpon

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc