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

From word to none

 [1/6] from: hallvard::ystad::helpinhand::com at: 18-Jun-2003 22:03


Hi I have a hash of values in a file, and in this hash, some values are none! The file looks like this: make hash! ["some string" none none "some string" 55 438 {"29621"} ] I go through the hash with foreach, like this: foreach [a b c] hash [ if none? b [ print "We've got a none! value" ] ] Now here's my problem: 'foreach gives the none values as word! values. How can I get them as "real" none! values? Thanks for any help, ~H

 [2/6] from: jskibinski:emailaccount at: 18-Jun-2003 13:30


Hi Hallvard,
>How can I get them as "real" none! values?
Use #[none] instead of none. This is a serialized form of 'none. It is supported by mold/all but this refinement works only in newer releases of Rebol. Jan _____________________________________________________________ Get an email address your friends will never forget... FREE! Become [YOU--EmailAccount--com] at http://www.emailaccount.com/

 [3/6] from: maximo:meteorstudios at: 18-Jun-2003 17:03


>> a: make hash! compose ["hi" (none)]
== [none]
>> probe type? a/2
none! == none!
>>
does this snippet help? -max

 [4/6] from: brett:codeconscious at: 19-Jun-2003 8:02


Arnaud had the same problem in his thread "sorting a serie ...." Jan's serialised form of none solution suprised me as I still haven't got used to that. But it a good way for future releases. An "old way" would be to use reduce on your block. Regards, Brett. ----- Original Message ----- From: "Hallvard Ystad" <[hallvard--ystad--helpinhand--com]> To: <[rebol-list--rebol--com]> Sent: Thursday, June 19, 2003 6:03 AM Subject: [REBOL] From word to none Hi I have a hash of values in a file, and in this hash, some values are none! The file looks like this: make hash! ["some string" none none "some string" 55 438 {"29621"} ] I go through the hash with foreach, like this: foreach [a b c] hash [ if none? b [ print "We've got a none! value" ] ] Now here's my problem: 'foreach gives the none values as word! values. How can I get them as "real" none! values? Thanks for any help, ~H

 [5/6] from: joel:neely:fedex at: 18-Jun-2003 17:02


Hi, again, Hallvard, REDUCE is your friend! Hallvard Ystad wrote:
> Hi > > I have a hash of values in a file, and in this hash, some values > are none! The file looks like this: > > make hash! ["some string" none none "some string" 55 438 {"29621"} ] >
REDUCE the block before making the hash:
>> foo: make hash! reduce ["some string" none none "some string" 55 438
{"29621"} ] == make hash! ["some string" none none "some string" 55 438 {"29621"}]
>> foreach thingie foo [print [type? thingie thingie]]
string some string none none none none string some string integer 55 integer 438 string "29621"
>>
-jn- -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446 Counting lines of code is to software development as counting bricks is to urban development.

 [6/6] from: g:santilli:tiscalinet:it at: 19-Jun-2003 10:01


Hi Hallvard, On Wednesday, June 18, 2003, 10:03:15 PM, you wrote: HY> make hash! ["some string" none none "some string" 55 438 {"29621"} ] If you're on a recent version of REBOL, you can write it as: #[hash! ["some string" #[none] #[none] "some string" 55 438 {"29621"}]] that will directly load into the correct values (without needing the DO to make the hash!). To save values in this format, use SAVE/ALL (or MOLD/ALL). HY> I go through the hash with foreach, like this: HY> foreach [a b c] hash [ HY> if none? b [ print "We've got a none! value" ] HY> ] Or, if you can't do the above because you're on an older version of REBOL, you could: forall hash [if 'none = pick hash 1 [hash/1: none]] hash: head hash Then you can use it normally. (If you don't have anything but strings in it, you could also just REDUCE it.) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r