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

Testing block of types

 [1/4] from: tim:johnsons-web at: 18-Oct-2003 9:53


Hello Rebols: ;; I would like to test the type of a value ;; or would agains a block of data types. ;; consider the console session below:
>> test: [number! series! money! time! date! char!]
== [number! series! money! time! date! char!]
>> type? test/1
== word!
>> find test 'number!
== [number! series! money! time! date! char!] ;; so far so good ;; Now test to see if the type of a value is in the 'test block
>> find test (type? 2)
== none ;; well, I would expect a hit here :( What notation do I need here to make a sucessful test. thanks! tim -- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com

 [2/4] from: nitsch-lists::netcologne::de at: 18-Oct-2003 20:19


Am Samstag, 18. Oktober 2003 19:53 schrieb Tim Johnson:
> Hello Rebols: > ;; I would like to test the type of a value
<<quoted lines omitted: 10>>
> == none ;; well, I would expect a hit here :( > What notation do I need here to make a sucessful test.
type?/word otherwise it return a datatype!, which molds the same as the word datatype!, but it is not. the word number! is set to the value number!, which is confusing. you can use reduce too. !>> mold/all reduce [number! series! money! time! date! char!] == {[#[datatype! number!] #[datatype! series!] #[datatype! money!] #[datatype! time!] #[datatype! date!] #[datatype! char!]]} ing.
>> type? type? 2
== datatype!
>> type? type?/word 2
== word!
> thanks! > tim
-Volker

 [3/4] from: tim:johnsons-web at: 18-Oct-2003 11:08


* Volker Nitsch <[nitsch-lists--netcologne--de]> [031018 10:40]: Thanks Volker: Talk about "hide in plain sight", now if I had just done >>help type? cheers tim
> Am Samstag, 18. Oktober 2003 19:53 schrieb Tim Johnson: > > Hello Rebols:
<<quoted lines omitted: 38>>
> To unsubscribe from this list, just send an email to > [rebol-request--rebol--com] with unsubscribe as the subject.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com

 [4/4] from: antonr:iinet:au at: 20-Oct-2003 12:59


This might help: foreach [cond code][ series? [print "series" break] number? [print "number"] ][if do reduce [cond value] code] when value is a series or number. Don't forget this either: value: 'hello switch type?/word value [integer! ["pants"] word! ["shirt"]] ;== "shirt" Anton.

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