]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 16 May 2009 22:56:06 +0000 (15:56 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 16 May 2009 22:56:06 +0000 (15:56 -0700)
basis/formatting/formatting-tests.factor
extra/math/compare/compare-docs.factor
extra/math/compare/compare-tests.factor
extra/math/compare/compare.factor

index c7e9fb985ef2e4b25b780b096fa1f905ab2aa960..c56372f023d19f337a388bd84217541c9465f91f 100644 (file)
@@ -77,6 +77,9 @@ IN: formatting.tests
 [ t ] [ "[####monkey]" "monkey" "[%'#10s]" sprintf = ] unit-test
 [ t ] [ "[many monke]" "many monkeys" "[%10.10s]" sprintf = ] unit-test
 
+[ t ] [ "{ 1, 2, 3 }" { 1 2 3 } "%[%s, %]" sprintf = ] unit-test
+[ t ] [ "{ 1:2, 3:4 }" H{ { 1 2 } { 3 4 } } "%[%s: %s %]" sprintf = ] unit-test
+
 
 [ "%H:%M:%S" strftime ] must-infer
 
@@ -95,3 +98,4 @@ IN: formatting.tests
 [ t ] [ "Thu Oct 09 12:03:15 2008" testtime "%c" strftime = ] unit-test
 [ t ] [ "PM" testtime "%p" strftime = ] unit-test
 
+
index 6c20db10fdf55d6efeacd17099ffd6d5194b54a6..4cbe1a1ae05d172e8e78b2523f31ac2a993914df 100644 (file)
@@ -18,6 +18,6 @@ HELP: negmin
 { $description "Returns the most-negative value, or zero if both are positive." } ;
 
 HELP: clamp
-{ $values { "a" number } { "value" number } { "b" number } { "x" number } }
+{ $values { "value" number } { "a" number } { "b" number } { "x" number } }
 { $description "Returns the value when between " { $snippet "a" } " and " { $snippet "b" } ", " { $snippet "a" } " if <= " { $snippet "a" } ", or " { $snippet "b" } " if >= " { $snippet "b" } "." } ;
 
index 272471fe5d1819d59d24c2d114d64c4c92464cd8..9accc8e98bd4572f96c4743744e61817f5ad6c0f 100644 (file)
@@ -15,7 +15,7 @@ IN: math.compare.tests
 [ -3 ] [ 1 -3 negmin ] unit-test
 [ -1 ] [ -1 3 negmin ] unit-test
 
-[ 0 ] [ 0 -1 2 clamp ] unit-test
-[ 1 ] [ 0 1 2 clamp ] unit-test
-[ 2 ] [ 0 3 2 clamp ] unit-test
+[ 0 ] [ -1 0 2 clamp ] unit-test
+[ 1 ] [ 1 0 2 clamp ] unit-test
+[ 2 ] [ 3 0 2 clamp ] unit-test
 
index 826f0ecf165cd6f08094a9f5c82f8a7e0daee2e1..93a8da7cf3a39df182658ed56b8a4932f3353b6a 100644 (file)
@@ -1,6 +1,8 @@
 ! Copyright (C) 2008 John Benediktsson.
 ! See http://factorcode.org/license.txt for BSD license
+
 USING: math math.order kernel ;
+
 IN: math.compare
 
 : absmin ( a b -- x )
@@ -15,5 +17,5 @@ IN: math.compare
 : negmin ( a b -- x )
     0 min min ;
 
-: clamp ( a value b -- x )
-    min max ;
+: clamp ( value a b -- x )
+    [ max ] [ min ] bi* ;