]> gitweb.factorcode.org Git - factor.git/commitdiff
Use s> and >s instead of r> and >r to avoid confusion
authorSamuel Tardieu <sam@rfc1149.net>
Thu, 27 Dec 2007 14:17:21 +0000 (15:17 +0100)
committerSamuel Tardieu <sam@rfc1149.net>
Thu, 27 Dec 2007 14:17:34 +0000 (15:17 +0100)
extra/math/algebra/algebra.factor

index 6ba445b0b07fc81ad70721f4fd7893d15f4e27aa..0dfd086e703d7d2b9f486d8414cd19358a57e78b 100644 (file)
@@ -1,27 +1,30 @@
 ! Copyright (c) 2007 Samuel Tardieu
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.ranges namespaces sequences vars math.algebra ;
+USING: kernel math math.ranges namespaces sequences vars ;
 IN: math.algebra
 
 <PRIVATE
 
-VARS: r-1 u-1 v-1 r u v ;
+! The traditional name for the first variable is "r", but we want to avoid
+! a redefinition of "r>" and ">r", so we chose to use "s" instead.
+
+VARS: s-1 u-1 v-1 s u v ;
 
 : init ( a b -- )
-  >r >r-1 0 >u 1 >u-1 1 >v 0 >v-1 ;
+  >s >s-1 0 >u 1 >u-1 1 >v 0 >v-1 ;
 
 : advance ( r u v -- )
-  v> >v-1 >v u> >u-1 >u r> >r-1 >r ; inline
+  v> >v-1 >v u> >u-1 >u s> >s-1 >s ; inline
 
 : step ( -- )
-  r-1> r> 2dup /mod drop [ * - ] keep u-1> over u> * - v-1> rot v> * -
+  s-1> s> 2dup /mod drop [ * - ] keep u-1> over u> * - v-1> rot v> * -
   advance ;
 
 PRIVATE>
 
 ! Extended Euclidian: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
 : ext-euclidian ( a b -- gcd u v )
-  [ init [ r> 0 > ] [ step ] [ ] while r-1> u-1> v-1> ] with-scope ; foldable
+  [ init [ s> 0 > ] [ step ] [ ] while s-1> u-1> v-1> ] with-scope ; foldable
 
 ! Inverse a in ring Z/bZ
 : ring-inverse ( a b -- i )