denominator integer- integer%
%> ;
+: unparse-complex ( num -- str )
+ >rect <% "#{ " % swap unparse % " " % unparse % " }" % %> ;
+
: >base ( num radix -- string )
#! Convert a number to a string in a certain base.
<namespace> [ "base" set unparse-integer ] bind ;
[ integer? ] [ unparse-integer ]
[ ratio? ] [ unparse-ratio ]
[ float? ] [ unparse-float ]
+ [ complex? ] [ unparse-complex ]
[ string? ] [ unparse-str ]
[ drop t ] [ <% "#<" % class-of % ">" % %> ]
] cond ;