minor tweaks

cvs
Slava Pestov 2006-01-17 08:08:47 +00:00
parent 6b49173e27
commit 3d4be6e4c7
2 changed files with 5 additions and 5 deletions

View File

@ -110,8 +110,8 @@ IN: math-contrib
: pdiff ( p -- p' ) : pdiff ( p -- p' )
#! Polynomial derivative. #! Polynomial derivative.
dup empty? [ [ length ] keep v* 1 swap tail ] unless ; dup length v* { 0 } ?head drop ;
: polyval ( x p -- p[x] ) : polyval ( p x -- p[x] )
#! Evaluate a polynomial. #! Evaluate a polynomial.
[ powers ] keep v. ; >r dup length r> powers v. ;

View File

@ -26,9 +26,9 @@ USING: errors kernel sequences math sequences-internals namespaces arrays ;
-rot (^mod) -rot (^mod)
] if ; foldable ] if ; foldable
: powers ( x n -- { 1 x x^2 x^3 ... } ) : powers ( n x -- { 1 x x^2 x^3 ... } )
#! Output sequence has n elements. #! Output sequence has n elements.
1 swap [ drop [ dupd * ] keep ] map 2nip ; <array> 1 [ * ] accumulate ;
: ** ( u v -- u*v' ) conjugate * ; inline : ** ( u v -- u*v' ) conjugate * ; inline