AltME: Rebol School

Messages

ChristianE
Gabriele
if you can add an extra word to your names, there is another way to do it:
>> names: [self field1 field2 field3]
== [self field1 field2 field3]
>> values: [#[none] "a" "b" "C"]    
== [none "a" "b" "C"]
>> names: use names reduce [names]  
== [self field1 field2 field3]
>> set names values                  
== [none "a" "b" "C"]
>> object: bound? first names      
>> object/self: object
>> probe object
make object! [
    field1: "a"
    field2: "b"
    field3: "C"
]
Up to you to decide if it's better or worse. :)

Endo
More clever award goes to ChirtianE, more interesting award goes to Gabriele :)
Sunanda
Thanks guys: lots of good ideas - as usual!
Gregg
change-each: func [
    [throw]
    "Change each value in the series by applying a function to it"
    'word   [word!] "Word or block of words to set each time (will be local)"
    series  [series!] "The series to traverse"
    body    [block!] "Block to evaluate. Return value to change current item to."
    /local do-body
][
    do-body: func reduce [[throw] word] body
    forall series [change/only series do-body series/1]
    ; The newer FORALL doesn't return the series at the tail like the old one
    ; did, but it will return the result of the block, which is CHANGE's result,
    ; so we need to explicitly return the series here.
    series
]
names: [field1 field2 field3]
values: ["a" "b" "C"]
o: context append change-each name names [to set-word! name] none
set o values
print mold o
Not sure what I was thinking. Should use MAP, not CHANGE-EACH.
R2 has MAP-EACH, so use that instead, so 'names isn't changed.
Then the entire solution is:
    o: context append map-each name names [to set-word! name] none
A MAP func would make it a little shorter, but R2 doesn't have one by default.

Marco
Nice addition to my "-each"s functions Gregg!

GiuseppeC
Could someone explain the difference between open/direct/lines/no-wait and open/direct/lines ?
The only one I have found is that if I read a client port with probe
COPY/part WAIT PORT 1
I get NONE
Otherwise
COPY/part PORT 1
I get []
But it should be more complex, I know I am missing something.
GiuseppeC
Forget my request: I have spent the whole day on REPL for TCP ports. It was interesting and intense but I have cleared many doubts and answered to questions.

Last message posted 188 weeks ago.