Split describe.factor up

slava 2006-08-01 01:30:06 +00:00
parent f3bd44083d
commit 9c84fe7018
7 changed files with 39 additions and 58 deletions

View File

@ -94,6 +94,7 @@ sequences vectors words ;
"/library/syntax/see.factor" "/library/syntax/see.factor"
"/library/syntax/parser.factor" "/library/syntax/parser.factor"
"/library/tools/summary.factor"
"/library/tools/describe.factor" "/library/tools/describe.factor"
"/library/tools/debugger.factor" "/library/tools/debugger.factor"
@ -292,6 +293,7 @@ sequences vectors words ;
"/library/test/test.facts" "/library/test/test.facts"
"/library/tools/word-tools.facts" "/library/tools/word-tools.facts"
"/library/tools/debugger.facts" "/library/tools/debugger.facts"
"/library/tools/summary.facts"
"/library/tools/describe.facts" "/library/tools/describe.facts"
"/library/tools/inspector.facts" "/library/tools/inspector.facts"
"/library/tools/listener.facts" "/library/tools/listener.facts"

View File

@ -1,5 +1,5 @@
! Copyright (C) 2004, 2005 Slava Pestov. ! Copyright (C) 2006 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: math-internals IN: math-internals
USING: errors generic kernel kernel-internals math ; USING: errors generic kernel kernel-internals math ;
@ -35,8 +35,6 @@ M: number = ( n n -- ? ) number= ;
: polar> ( abs arg -- z ) cis * ; inline : polar> ( abs arg -- z ) cis * ; inline
: quadrant ( z -- n ) >rect >r 0 >= 0 1 ? r> 0 >= 0 3 ? bitxor ;
M: complex absq >rect [ sq ] 2apply + ; M: complex absq >rect [ sq ] 2apply + ;
IN: math-internals IN: math-internals

View File

@ -49,10 +49,6 @@ HELP: polar> "( abs arg -- z )"
{ $values { "z" "a complex number" } { "abs" "a non-negative real number" } { "arg" "a real number" } } { $values { "z" "a complex number" } { "abs" "a non-negative real number" } { "arg" "a real number" } }
{ $description "Converts an absolute value and argument (polar form) to a complex number." } ; { $description "Converts an absolute value and argument (polar form) to a complex number." } ;
HELP: quadrant "( z -- n )"
{ $values { "z" "a complex number" } { "n" "0, 1, 2, or 3" } }
{ $description "If the imaginary axis runs from bottom to top and the real axis runs from left to right, the quadrants of the complex plane run anti-clockwise starting from the positive real axis:" { $code "1|0" "---" "2|3" } } ;
HELP: 2>rect "( x y -- xr xi yr yi )" HELP: 2>rect "( x y -- xr xi yr yi )"
{ $values { "x" "a complex number" } { "y" "a complex number" } { "xr" "real part of " { $snippet "x" } } { "xi" "imaginary part of " { $snippet "x" } } { "yr" "real part of " { $snippet "y" } } { "yi" "imaginary part of " { $snippet "y" } } } { $values { "x" "a complex number" } { "y" "a complex number" } { "xr" "real part of " { $snippet "x" } } { "xi" "imaginary part of " { $snippet "x" } } { "yr" "real part of " { $snippet "y" } } { "yi" "imaginary part of " { $snippet "y" } } }
{ $description "Extracts real and imaginary components of two numbers at once." } ; { $description "Extracts real and imaginary components of two numbers at once." } ;

View File

@ -5,31 +5,8 @@ USING: arrays generic hashtables io kernel kernel-internals
math namespaces prettyprint sequences strings styles vectors math namespaces prettyprint sequences strings styles vectors
words ; words ;
GENERIC: summary ( object -- string )
: sign-string ( n -- string )
0 > "a positive " "a negative " ? ;
M: integer summary
dup zero? [
"a " "zero "
] [
dup sign-string over 2 mod zero? "even " "odd " ?
] if rot class word-name append3 ;
M: real summary
dup sign-string swap class word-name append ;
M: complex summary
"a complex number in the "
swap quadrant { "first" "second" "fourth" "third" } nth
" quadrant" append3 ;
GENERIC: sheet ( obj -- sheet ) GENERIC: sheet ( obj -- sheet )
M: object summary
"an instance of the " swap class word-name " class" append3 ;
: slot-sheet ( obj -- sheet ) : slot-sheet ( obj -- sheet )
dup class "slots" word-prop dup class "slots" word-prop
dup [ third ] map -rot dup [ third ] map -rot
@ -53,29 +30,6 @@ M: hashtable summary
M: hashtable sheet hash>alist flip ; M: hashtable sheet hash>alist flip ;
M: word summary ( word -- )
dup word-vocabulary [
dup interned?
"a word in the " "a word orphaned from the " ?
swap word-vocabulary " vocabulary" append3
] [
drop "a uniquely generated symbol"
] if ;
M: input summary ( input -- )
"Input: " swap input-string
dup string? [ unparse-short ] unless append ;
M: vocab-link summary ( vocab-link -- )
[
vocab-link-name dup %
" vocabulary (" %
words length #
" words)" %
] "" make ;
DEFER: describe
: sheet. ( sheet -- ) : sheet. ( sheet -- )
flip dup empty? [ flip dup empty? [
drop drop

View File

@ -1,10 +1,6 @@
IN: inspector IN: inspector
USING: help io kernel prettyprint words ; USING: help io kernel prettyprint words ;
HELP: summary "( object -- string )"
{ $values { "object" "an object" } { "string" "a string" } }
{ $contract "Outputs a brief description of the object." } ;
HELP: sheet "( object -- sheet )" HELP: sheet "( object -- sheet )"
{ $values { "object" "an object" } { "sheet" "a sequence of sequences" } } { $values { "object" "an object" } { "sheet" "a sequence of sequences" } }
{ $contract "Outputs a representation of the object for the " { $link describe } " word, which is a table where each row corresponds to an object slot, and consists of a number of columns, presumably including the slot name and value." } ; { $contract "Outputs a representation of the object for the " { $link describe } " word, which is a table where each row corresponds to an object slot, and consists of a number of columns, presumably including the slot name and value." } ;

View File

@ -0,0 +1,29 @@
! Copyright (C) 2005, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: inspector
GENERIC: summary ( object -- string )
M: object summary
"an instance of the " swap class word-name " class" append3 ;
M: word summary ( word -- )
dup word-vocabulary [
dup interned?
"a word in the " "a word orphaned from the " ?
swap word-vocabulary " vocabulary" append3
] [
drop "a uniquely generated symbol"
] if ;
M: input summary ( input -- )
"Input: " swap input-string
dup string? [ unparse-short ] unless append ;
M: vocab-link summary ( vocab-link -- )
[
vocab-link-name dup %
" vocabulary (" %
words length #
" words)" %
] "" make ;

View File

@ -0,0 +1,6 @@
IN: inspector
USING: help ;
HELP: summary "( object -- string )"
{ $values { "object" "an object" } { "string" "a string" } }
{ $contract "Outputs a brief description of the object." } ;