documentation updates, minor code cleanups
parent
065b93dbdf
commit
1cbccb5956
31
CHANGES.txt
31
CHANGES.txt
|
@ -7,13 +7,6 @@ Factor 0.76:
|
||||||
supports styled text output, presentations, and an
|
supports styled text output, presentations, and an
|
||||||
automatically-updated data stack display.
|
automatically-updated data stack display.
|
||||||
|
|
||||||
- The number of generations used for garbage collection can now be set
|
|
||||||
with the +G command line switch. You must specify at least 2
|
|
||||||
generations.
|
|
||||||
|
|
||||||
- Only 2 generations are used by default now, since there seems to be no
|
|
||||||
performance benefit to having 3 after running some brief benchmarks.
|
|
||||||
|
|
||||||
- The following formely list-specific words are now generic:
|
- The following formely list-specific words are now generic:
|
||||||
|
|
||||||
all? all-with? subset subset-with fiber? prune
|
all? all-with? subset subset-with fiber? prune
|
||||||
|
@ -27,8 +20,21 @@ Factor 0.76:
|
||||||
|
|
||||||
- The nreverse word has been removed.
|
- The nreverse word has been removed.
|
||||||
|
|
||||||
- reversed ( seq -- seq ) outputs a new sequence that shares structure
|
- The , word no longer accepts a string as input. Formely, the following
|
||||||
with the given sequence, but presents elements in reverse order.
|
two lines were equivalent:
|
||||||
|
|
||||||
|
[ "Hello" , " world" , ] make-string
|
||||||
|
[ "Hello" % " world" % ] make-string
|
||||||
|
|
||||||
|
Now, the former raises a type error.
|
||||||
|
|
||||||
|
- The stream-write, stream-write-attr, write and write-attr generic
|
||||||
|
words no longer accept a character as an argument. Use the new
|
||||||
|
stream-write1 and write1 generic words to write single characters.
|
||||||
|
|
||||||
|
- reverse-slice ( seq -- seq ) outputs a new sequence that shares
|
||||||
|
structure with the given sequence, but presents elements in reverse
|
||||||
|
order.
|
||||||
|
|
||||||
- Many improvements to the matrices library.
|
- Many improvements to the matrices library.
|
||||||
|
|
||||||
|
@ -39,6 +45,13 @@ Factor 0.76:
|
||||||
|
|
||||||
- Improved inspector. Call it with inspect ( obj -- ).
|
- Improved inspector. Call it with inspect ( obj -- ).
|
||||||
|
|
||||||
|
- The number of generations used for garbage collection can now be set
|
||||||
|
with the +G command line switch. You must specify at least 2
|
||||||
|
generations.
|
||||||
|
|
||||||
|
- Only 2 generations are used by default now, since there seems to be no
|
||||||
|
performance benefit to having 3 after running some brief benchmarks.
|
||||||
|
|
||||||
- Fixed bug where images saved from the jEdit plugin would fail to
|
- Fixed bug where images saved from the jEdit plugin would fail to
|
||||||
start.
|
start.
|
||||||
|
|
||||||
|
|
851
doc/handbook.tex
851
doc/handbook.tex
File diff suppressed because it is too large
Load Diff
|
@ -10,6 +10,7 @@ C: reversed [ set-delegate ] keep ;
|
||||||
: reversed@ delegate [ length swap - 1 - ] keep ;
|
: reversed@ delegate [ length swap - 1 - ] keep ;
|
||||||
M: reversed nth ( n seq -- elt ) reversed@ nth ;
|
M: reversed nth ( n seq -- elt ) reversed@ nth ;
|
||||||
M: reversed set-nth ( elt n seq -- ) reversed@ set-nth ;
|
M: reversed set-nth ( elt n seq -- ) reversed@ set-nth ;
|
||||||
|
M: reversed thaw ( seq -- seq ) delegate reverse ;
|
||||||
|
|
||||||
! A repeated sequence is the same element n times.
|
! A repeated sequence is the same element n times.
|
||||||
TUPLE: repeated length object ;
|
TUPLE: repeated length object ;
|
||||||
|
|
|
@ -41,12 +41,14 @@ G: each ( seq quot -- | quot: elt -- )
|
||||||
G: 2map ( seq seq quot -- seq | quot: elt elt -- elt )
|
G: 2map ( seq seq quot -- seq | quot: elt elt -- elt )
|
||||||
[ over ] [ type ] ; inline
|
[ over ] [ type ] ; inline
|
||||||
|
|
||||||
G: find [ over ] [ type ] ; inline
|
G: find ( seq quot -- i elt )
|
||||||
|
[ over ] [ type ] ; inline
|
||||||
|
|
||||||
: find-with ( obj seq quot -- i elt )
|
: find-with ( obj seq quot -- i elt )
|
||||||
swap [ with rot ] find 2swap 2drop ; inline
|
swap [ with rot ] find 2swap 2drop ; inline
|
||||||
|
|
||||||
G: find* [ over ] [ type ] ; inline
|
G: find* ( i seq quot -- i elt )
|
||||||
|
[ over ] [ type ] ; inline
|
||||||
|
|
||||||
: find-with* ( obj i seq quot -- i elt )
|
: find-with* ( obj i seq quot -- i elt )
|
||||||
-rot [ with rot ] find* 2swap 2drop ; inline
|
-rot [ with rot ] find* 2swap 2drop ; inline
|
||||||
|
|
|
@ -14,6 +14,8 @@ IN: vectors
|
||||||
: >vector ( list -- vector )
|
: >vector ( list -- vector )
|
||||||
dup length <vector> [ swap nappend ] keep ;
|
dup length <vector> [ swap nappend ] keep ;
|
||||||
|
|
||||||
|
M: repeated thaw >vector ;
|
||||||
|
|
||||||
M: vector clone ( vector -- vector )
|
M: vector clone ( vector -- vector )
|
||||||
>vector ;
|
>vector ;
|
||||||
|
|
||||||
|
|
|
@ -229,4 +229,4 @@ PREDICATE: word tuple-class metaclass tuple = ;
|
||||||
2drop t
|
2drop t
|
||||||
] [
|
] [
|
||||||
over [ >r delegate r> is? ] [ 2drop f ] ifte
|
over [ >r delegate r> is? ] [ 2drop f ] ifte
|
||||||
] ifte ;
|
] ifte ; inline
|
||||||
|
|
|
@ -34,7 +34,6 @@ DEFER: t?
|
||||||
: >boolean t f ? ; inline
|
: >boolean t f ? ; inline
|
||||||
: and ( a b -- a&b ) f ? ; inline
|
: and ( a b -- a&b ) f ? ; inline
|
||||||
: or ( a b -- a|b ) t swap ? ; inline
|
: or ( a b -- a|b ) t swap ? ; inline
|
||||||
: xor ( a b -- a^b ) dup not swap ? ; inline
|
|
||||||
|
|
||||||
: cpu ( -- arch ) 7 getenv ;
|
: cpu ( -- arch ) 7 getenv ;
|
||||||
: os ( -- os ) 11 getenv ;
|
: os ( -- os ) 11 getenv ;
|
||||||
|
|
|
@ -5,6 +5,8 @@ USING: errors generic kernel lists math namespaces sequences
|
||||||
vectors ;
|
vectors ;
|
||||||
|
|
||||||
! Vector operations
|
! Vector operations
|
||||||
|
: vneg ( v -- v ) [ neg ] map ;
|
||||||
|
|
||||||
: n*v ( n vec -- vec ) [ * ] map-with ;
|
: n*v ( n vec -- vec ) [ * ] map-with ;
|
||||||
: v*n ( vec n -- vec ) swap n*v ;
|
: v*n ( vec n -- vec ) swap n*v ;
|
||||||
: n/v ( n vec -- vec ) [ / ] map-with ;
|
: n/v ( n vec -- vec ) [ / ] map-with ;
|
||||||
|
@ -14,10 +16,10 @@ vectors ;
|
||||||
: v- ( v v -- v ) [ - ] 2map ;
|
: v- ( v v -- v ) [ - ] 2map ;
|
||||||
: v* ( v v -- v ) [ * ] 2map ;
|
: v* ( v v -- v ) [ * ] 2map ;
|
||||||
: v/ ( v v -- v ) [ / ] 2map ;
|
: v/ ( v v -- v ) [ / ] 2map ;
|
||||||
: vand ( v v -- v ) [ and ] 2map ;
|
|
||||||
: vor ( v v -- v ) [ or ] 2map ;
|
|
||||||
: vmax ( v v -- v ) [ max ] 2map ;
|
: vmax ( v v -- v ) [ max ] 2map ;
|
||||||
: vmin ( v v -- v ) [ min ] 2map ;
|
: vmin ( v v -- v ) [ min ] 2map ;
|
||||||
|
: vand ( v v -- v ) [ and ] 2map ;
|
||||||
|
: vor ( v v -- v ) [ or ] 2map ;
|
||||||
: v< ( v v -- v ) [ < ] 2map ;
|
: v< ( v v -- v ) [ < ] 2map ;
|
||||||
: v<= ( v v -- v ) [ <= ] 2map ;
|
: v<= ( v v -- v ) [ <= ] 2map ;
|
||||||
: v> ( v v -- v ) [ > ] 2map ;
|
: v> ( v v -- v ) [ > ] 2map ;
|
||||||
|
@ -26,12 +28,10 @@ vectors ;
|
||||||
: vbetween? ( v from to -- v )
|
: vbetween? ( v from to -- v )
|
||||||
>r over >r v>= r> r> v<= vand ;
|
>r over >r v>= r> r> v<= vand ;
|
||||||
|
|
||||||
: vneg ( v -- v ) [ neg ] map ;
|
|
||||||
|
|
||||||
: sum ( v -- n ) 0 [ + ] reduce ;
|
: sum ( v -- n ) 0 [ + ] reduce ;
|
||||||
: product 1 [ * ] reduce ;
|
: product 1 [ * ] reduce ;
|
||||||
: conj ( v -- ? ) t [ and ] reduce ;
|
: conj ( v -- ? ) [ ] all? ;
|
||||||
: disj ( v -- ? ) f [ or ] reduce ;
|
: disj ( v -- ? ) [ ] contains? ;
|
||||||
|
|
||||||
: set-axis ( x y axis -- v )
|
: set-axis ( x y axis -- v )
|
||||||
2dup v* >r >r drop dup r> v* v- r> v+ ;
|
2dup v* >r >r drop dup r> v* v- r> v+ ;
|
||||||
|
|
|
@ -4,4 +4,4 @@ IN: matrices
|
||||||
USING: kernel math ;
|
USING: kernel math ;
|
||||||
|
|
||||||
: norm ( vec -- n ) norm-sq sqrt ;
|
: norm ( vec -- n ) norm-sq sqrt ;
|
||||||
: normalize ( vec -- vec ) [ norm recip ] keep n*v ;
|
: normalize ( vec -- vec ) dup norm v/n ;
|
||||||
|
|
Loading…
Reference in New Issue