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

Composing lists in lists

 [1/6] from: massung::gmail::com at: 8-Mar-2006 19:25


Another question, folks (I'll be full of them for a bit). And, I appreciate the quick answers I've been getting from everyone :-) How do I compose a list in a list? For example:
>> list: [a b c]
== [a b c]
>> compose [ 1 (list) ]
== [1 a b c] So, I would actually like it to be: [1 [a b c]]. Now, I can force this by doing something like:
>> list: [ [a b c] ] >> compose [ 1 (list) ]
== [1 [a b c]] But this not only sure feels like voodoo-hackery, but just wrong. I'm sorry if this is a trivial question and the answer is in the REBOL dictionary, but looking through all the series functions, compose was the closest I got to what I was looking for. Jeff M. -- massung-gmail.com

 [2/6] from: tomc:cs:uoregon at: 8-Mar-2006 17:29


Hi Jeff ? is also your friend.
>> ? compose
USAGE: COMPOSE value /deep /only DESCRIPTION: Evaluates a block of expressions, only evaluating parens, and returns a block . COMPOSE is a native value. ARGUMENTS: value -- Block to compose (Type: any) REFINEMENTS: /deep -- Compose nested blocks /only -- Inserts a block value as a block
>> list: [a b c]
== [a b c]
>> compose/only [ 1 2 (list) 3]
== [1 2 [a b c] 3]
>>
Jeff Massung wrote:
> Another question, folks (I'll be full of them for a bit). And, I appreciate > the quick answers I've been getting from everyone :-)
<<quoted lines omitted: 15>>
> -- > massung-gmail.com
-- ... nice weather eh tomc-cs.uoregon.edu

 [3/6] from: massung:gma:il at: 8-Mar-2006 19:32


I am a happy man. Thank you. And, I don't know how I missed that. Thanks again! Jeff M. On 3/8/06, Tom Conlin <tomc-cs.uoregon.edu> wrote:
> Hi Jeff > ? is also your friend.
<<quoted lines omitted: 55>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- massung-gmail.com

 [4/6] from: volker:nitsch::gmail at: 9-Mar-2006 4:59


Also look for 'append and friends, series-function. Rebol is not pure functional, it happily changes its variables. So blocks (rebols "lists") are usually build by appending values to it, not by composing new blocks. Means you would 'compose the code for a button, but 'append a lot of buttons to a layout. On 3/9/06, Jeff Massung <massung-gmail.com> wrote:
> I am a happy man. Thank you. And, I don't know how I missed that. Thanks > again!
<<quoted lines omitted: 76>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [5/6] from: pwawood::gmail::com at: 9-Mar-2006 14:03


Jeff Volker's advice applied to your simple example:
>> list: [a b c]
== [a b c]
>> append/only newlist: [1] list
== [1 [a b c]]
>> newlist
== [1 [a b c]] Regards Peter On Thursday, Mar 9, 2006, at 11:59 Asia/Kuala_Lumpur, Volker Nitsch wrote:

 [6/6] from: volker::nitsch::gmail::com at: 9-Mar-2006 8:07


On 3/9/06, Peter Wood <pwawood-gmail.com> wrote:
> Jeff > > Volker's advice applied to your simple example: > > >> list: [a b c] > == [a b c] > >> append/only newlist: [1] list
append/only newlist: copy[1] list never forget the copy! That means trouble in rebol. It is *very* side-effective by default. Also, In this case i prefer 'compose. I use it for "templates". But in a loop appending multiple things 'append is better. The 'map of rebol is typically: out: copy[] foreach val data[ append/only out compose[something] ] return out
> == [1 [a b c]] > >> newlist
<<quoted lines omitted: 20>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted