Type detection: Difference between revisions

added Factor
(Added solution for D)
(added Factor)
Line 135:
S
typeof(null)</pre>
 
=={{header|Factor}}==
Using method dispatch:
<lang>USING: arrays formatting io kernel math prettyprint sequences
strings ;
IN: rosetta-code.type-detection
 
GENERIC: myprint ( object -- )
 
M: object myprint drop "I don't know how to print this." print ;
M: string myprint "I'm a string: \"%s\"\n" printf ;
M: fixnum myprint "I'm a fixnum: " write . ;
M: array myprint "I'm an array: { " write
[ pprint bl ] each "}" print ;
"Hello world." myprint
{ 1 2 3 4 5 } myprint
123 myprint
3.1415 myprint</lang>
{{out}}
<pre>
I'm a string: "Hello world."
I'm an array: { 1 2 3 4 5 }
I'm a fixnum: 123
I don't know how to print this.
</pre>
 
== {{header|J}} ==
1,827

edits