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

howto_convert?

 [1/6] from: riachtchenko:docutec at: 29-Nov-2000 11:14


Hi, since i read it' would be all easy in rebol, i tried obscure:
>> account: make object! [
[ name: none]
>> a_1: :account >> a_2: :account >> a_2/name: "sascha"
== "sascha"
>> a_1/name: "mascha"
== "mascha"
>> foreach obj [acc_1 acc_2][
[ probe obj/name] ** Script Error: Cannot use path on word! value. ** Where: probe obj/name
>>
I did't found how it can be converted in a right way. Thanks, Sascha

 [2/6] from: lmecir:mbox:vol:cz at: 29-Nov-2000 17:47


Hi Sascha, this could be what you need: account: make object! [ name: none ] a_1: make account [] a_2: make account [] a_2/name: "sascha" a_1/name: "mascha" foreach obj reduce [a_1 a_2] [ probe obj/name ] Regards Ladislav (Rebol Rebol)

 [3/6] from: joel:neely:fedex at: 29-Nov-2000 11:03


Hi, Sascha, You've got two problems with this code (maybe three...) [rebol-bounce--rebol--com] wrote:
> Hi, > since i read it' would be all easy in rebol,
<<quoted lines omitted: 12>>
> ** Where: probe obj/name > >>
Problem 1) Your block should have read [a_1 a_2] instead of [acc_1 acc_2] because of what your code defined. Problem 2) Your block needs to be reduced before being used in the loop. The block [a_1 a_2] is just a block containing the two words 'a_1 and 'a_2 until it is reduced (or otherwise evaluated). As you seem to expect to get to the objects referenced by those words, instead of the words themselves, you need to reduce the list. Possible Problem 3) I'm really unclear on why you set both of your words to refer to the same account object. If you really meant to create distinct objects, you need to make new ones for the two words. Taking all the above into account, here's code that behaves the way I infer that you were expecting.
>> account: make object! [name: none] >> a1: make account [] >> a2: make account [] >> a1/name: "sascha"
== "sascha"
>> a2/name: "mascha"
== "mascha"
>> foreach obj reduce [a1 a2] [print obj/name]
sascha mascha Note that you could have initialized the two new(er) objects by a1: make account [name: "sascha"] a2: make account [name: "mascha"] combining object construction and default value replacement into a single phrase for each. Hope this helps! -jn- -- ; Joel Neely [joel--neely--fedex--com] 901-263-4460 38017/HKA/9677 REBOL [] foreach [order string] sort/skip reduce [ true "!" false head reverse "rekcah" none "REBOL " prin "Just " "another " ] 2 [prin string] print ""

 [4/6] from: riachtchenko:docutec at: 29-Nov-2000 18:11


Thanks Ladislav, cloning and reduce works OK Sascha Ladislav Mecir wrote:

 [5/6] from: riachtchenko:docutec at: 29-Nov-2000 18:17


Thank you gays Ladislav and Joel! Sascha.

 [6/6] from: riachtchenko::docutec::de at: 30-Nov-2000 13:58


Hi Joel, since you were so kind to provide also this:
> ; Joel Neely [joel--neely--fedex--com] 901-263-4460 38017/HKA/9677 > REBOL [] foreach [order string] sort/skip reduce [ true "!" > false head reverse "rekcah" none "REBOL " prin "Just " "another " > ] 2 [prin string] print "" > --
i'd ask you- after that:
>>sort/skip reduce [ true "!"
false head reverse "rekcah" none "REBOL " prin "Just " "another " ] 2 Just == [unset "another " none "REBOL " false "hacker" true "!"] ;the same in tracer: ... Result: [true "!" false "hacker" none "REBOL " unset "another "] (block) Trace: 2 (integer) Result: [...] (block) == [unset "another " none "REBOL " false "hacker" true "!"] ;seems, sort sorts here another way as in:
>> sort/skip [true "!" false "hacker" none "REBOL " unset "another "] 2
== [false "hacker" none "REBOL " true "!" unset "another "] ? Thanks, Sascha.

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