 : object-summary ( object -- string ) class-of name>> ; inline
 
 : container-summary ( obj size word -- str )
-    [ object-summary ] 2dip "%s with %d %s" sprintf ;
+    [ object-summary ] 2dip [
+        [ % " with " % ] [ # ] [ " " % % ] tri*
+    ] "" make ;
 
 GENERIC: tuple-summary ( object -- string )
 

    dup assoc-size "entries" container-summary ;

M: object tuple-summary
    class-of "a %s tuple" sprintf ;

M: unordered-set tuple-summary
    dup cardinality "members" container-summary ;

! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs classes continuations kernel make math
math.parser sequences sets strings ;
IN: summary

GENERIC: summary ( object -- string )
