Split describe.factor up
parent
f3bd44083d
commit
9c84fe7018
|
|
@ -94,6 +94,7 @@ sequences vectors words ;
|
|||
"/library/syntax/see.factor"
|
||||
"/library/syntax/parser.factor"
|
||||
|
||||
"/library/tools/summary.factor"
|
||||
"/library/tools/describe.factor"
|
||||
"/library/tools/debugger.factor"
|
||||
|
||||
|
|
@ -292,6 +293,7 @@ sequences vectors words ;
|
|||
"/library/test/test.facts"
|
||||
"/library/tools/word-tools.facts"
|
||||
"/library/tools/debugger.facts"
|
||||
"/library/tools/summary.facts"
|
||||
"/library/tools/describe.facts"
|
||||
"/library/tools/inspector.facts"
|
||||
"/library/tools/listener.facts"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
! Copyright (C) 2004, 2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
! Copyright (C) 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: math-internals
|
||||
USING: errors generic kernel kernel-internals math ;
|
||||
|
||||
|
|
@ -35,8 +35,6 @@ M: number = ( n n -- ? ) number= ;
|
|||
|
||||
: 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 + ;
|
||||
|
||||
IN: math-internals
|
||||
|
|
|
|||
|
|
@ -49,10 +49,6 @@ HELP: polar> "( abs arg -- z )"
|
|||
{ $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." } ;
|
||||
|
||||
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 )"
|
||||
{ $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." } ;
|
||||
|
|
|
|||
|
|
@ -5,31 +5,8 @@ USING: arrays generic hashtables io kernel kernel-internals
|
|||
math namespaces prettyprint sequences strings styles vectors
|
||||
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 )
|
||||
|
||||
M: object summary
|
||||
"an instance of the " swap class word-name " class" append3 ;
|
||||
|
||||
: slot-sheet ( obj -- sheet )
|
||||
dup class "slots" word-prop
|
||||
dup [ third ] map -rot
|
||||
|
|
@ -53,29 +30,6 @@ M: hashtable summary
|
|||
|
||||
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 -- )
|
||||
flip dup empty? [
|
||||
drop
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
IN: inspector
|
||||
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 )"
|
||||
{ $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." } ;
|
||||
|
|
|
|||
|
|
@ -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 ;
|
||||
|
|
@ -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." } ;
|
||||
Loading…
Reference in New Issue