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

[REBOL] Re: 'get'ing a 'word from a block

From: tim:johnsons-web at: 1-Jan-2003 8:00

Thanks to all for helping me to find my solution! regards -tim- * Volker Nitsch <[nitsch-lists--netcologne--de]> [021231 23:10]:
> d: [a b c] > blk: [1 2 3 4 5 6 7 8 9] > test: func [row [block!]] [?? row ?? a probe reduce row] > forskip blk length? d[ set d blk test d] > blk: head blk ;if you need blk later > > row: [a b c] > a: 1 > [1 2 3] > row: [a b c] > a: 4 > [4 5 6] > row: [a b c] > a: 7 > [7 8 9] > > Tim Johnson wrote: > > >Thank you Anton! I forgot about 'bind. > > > >I'm still in the dark a bit though, because > >I really want to get the values for 'a 'b 'c > >in 'test > >If I rewrite test as : > > test: func [row [block!]][?? row ?? a] > > > >>>foreach :d blk code: [ > >>> > >[ ?? a ?? b ?? c > >[ test reduce bind d 'a > >[ ] > >a: 1 > >b: 2 > >c: 3 > >row: [1 2 3] > >** Script Error: a has no value > >** Where: rejoin > >** Near: mold name: get name > > > >If possible, I would want to get > >'row as [a b c] > >and 'get 1 from a. > > > >Is this possible? > > > >And Happy New Year! > >-tim- > > > >* Anton <[anton--lexicon--net]> [021231 21:10]: > > > >>Well, > >> > >>Your block d contains three words, a b c, whose > >>context is... in that block... (I think). > >>You need to bind the words in the d block into > >>the foreach's context (which we can get to using > >>'a as an example word in that context.) > >> > >>Having bound the words in d to the foreach context, > >>they are still simply [a b c], so you need to > >>reduce the block get a block of values out. > >> > >>So a bit of binding and reducing and you are fixed: > >> > >> d: [a b c] > >> blk: [1 2 3 4 5 6 7 8 9] > >> test: func [row [block!]][?? row] > >> foreach :d blk code: [ > >> ?? a ?? b ?? c > >> test reduce bind d 'a > >> ] > >> > >>Anton. > >> > >>>Hello Rebols: > >>> I have an example below where foreach sets a block > >>>of values, but I don't know how to retain those > >>>values within the block when I pass the block to > >>>another function: > >>> > >>>>>d: [a b c] > >>>>> > >>>== [a b c] > >>> > >>>>>blk: [1 2 3 4 5 6 7 8 9] > >>>>> > >>>== [1 2 3 4 5 6 7 8 9] > >>> > >>>>>test: func[row[block!]][?? row ?? a] > >>>>>foreach :d blk[?? a ?? b ?? c test d] > >>>>> > >>>a: 1 > >>>b: 2 > >>>c: 3 > >>>; foreach sets the values in the block correctly > >>>row: [a b c] > >>>; the words are passed in the block to 'test > >>>** Script Error: a has no value > >>>** Where: rejoin > >>>** Near: mold name: get name > >>>; alas, can't get the value > >>> > >>>What am I doing wrong here? > >>>TIA > >>>-- > >>>Tim Johnson <[tim--johnsons-web--com]> > >>> > > > > -volker > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com