From c6fd20b1079b27e5e022bce9693942f1e0ed6d58 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 4 Jul 2010 09:23:43 -0700 Subject: [PATCH] math.polynomials: update pdiff for no-integers-as-sequences (reported by rswarbrick) --- basis/math/polynomials/polynomials-tests.factor | 2 ++ basis/math/polynomials/polynomials.factor | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/basis/math/polynomials/polynomials-tests.factor b/basis/math/polynomials/polynomials-tests.factor index 08f81a5bfa..22ac89bc7d 100644 --- a/basis/math/polynomials/polynomials-tests.factor +++ b/basis/math/polynomials/polynomials-tests.factor @@ -31,3 +31,5 @@ IN: math.polynomials.tests [ t ] [ { 1 1 1 } { 1 1 1 } p= ] unit-test [ { 0 0 } { 1 1 } ] [ { 1 1 1 1 } { 1 1 } pgcd ] unit-test +[ { 10 200 3000 } ] [ { 1 10 100 1000 } pdiff ] unit-test + diff --git a/basis/math/polynomials/polynomials.factor b/basis/math/polynomials/polynomials.factor index 57c3c5b8ef..df3900c92f 100644 --- a/basis/math/polynomials/polynomials.factor +++ b/basis/math/polynomials/polynomials.factor @@ -88,7 +88,7 @@ PRIVATE> [ V{ 0 } clone V{ 1 } clone ] 2dip swap (pgcd) [ >array ] bi@ ; : pdiff ( p -- p' ) - dup length v* { 0 } ?head drop ; + dup length iota v* unclip drop ; : polyval ( x p -- p[x] ) [ length swap powers ] [ nip ] 2bi v. ;