]> gitweb.factorcode.org Git - factor.git/commitdiff
update cond/case
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 11 Apr 2008 17:56:48 +0000 (12:56 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 11 Apr 2008 17:56:48 +0000 (12:56 -0500)
15 files changed:
extra/koszul/koszul.factor
extra/lazy-lists/lazy-lists.factor
extra/logging/parser/parser.factor
extra/logging/server/server.factor
extra/match/match.factor
extra/math/functions/functions.factor
extra/math/miller-rabin/miller-rabin.factor
extra/math/primes/primes.factor
extra/multi-methods/multi-methods.factor
extra/odbc/odbc.factor
extra/ogg/player/player.factor
extra/opengl/gl/extensions/extensions.factor
extra/optimizer/debugger/debugger.factor
extra/oracle/oracle.factor
extra/porter-stemmer/porter-stemmer.factor

index add37173b753a043aee9d1e5e0cee917f8640540..e3c2997d0b5ebc3bb2414d767ad2b9373b214fd8 100755 (executable)
@@ -15,7 +15,7 @@ IN: koszul
         { [ dup number? ] [ { } associate ] }
         { [ dup array? ] [ 1 swap associate ] }
         { [ dup hashtable? ] [ ] }
-        { [ t ] [ 1array >alt ] }
+        [ 1array >alt ]
     } cond ;
 
 : canonicalize
@@ -31,10 +31,10 @@ SYMBOL: terms
 ! Printing elements
 : num-alt. ( n -- str )
     {
-        { [ dup 1 = ] [ drop " + " ] }
-        { [ dup -1 = ] [ drop " - " ] }
-        { [ t ] [ number>string " + " prepend ] }
-    } cond ;
+        { 1 [ " + " ] }
+        { -1 [ " - " ] }
+        [ number>string " + " prepend ]
+    } case ;
 
 : (alt.) ( basis n -- str )
     over empty? [
index d13848498fe1e9a359d9018699c65f7920af2d21..ebd2fe9f2e2030e76cf083b683e1962ccaf8c9b7 100644 (file)
@@ -321,7 +321,7 @@ M: sequence-cons nil? ( sequence-cons -- bool )
   {
     { [ dup sequence? ] [ 0 swap seq>list ] }
     { [ dup list?     ] [ ] }
-    { [ t ] [ "Could not convert object to a list" throw ] }
+    [ "Could not convert object to a list" throw ]
   } cond ;
 
 TUPLE: lazy-concat car cdr ;
index 015861501ecdfd18345479eeb4f75db5b14012ff..c6b073e50199d2215bc20e779f63b8819acd194a 100755 (executable)
@@ -66,7 +66,7 @@ MEMO: 'log-line' ( -- parser )
             parse-log-line {\r
                 { [ dup malformed? ] [ malformed-line ] }\r
                 { [ dup multiline? ] [ add-multiline ] }\r
-                { [ t ] [ , ] }\r
+                [ , ]\r
             } cond\r
         ] each\r
     ] { } make ;\r
index bed6a2fec33345e244b94e014f78f07dc7147f1b..c6aee034cc75f99b9727a940302ac129ccfee3a1 100755 (executable)
@@ -40,10 +40,10 @@ SYMBOL: log-files
     rot [ empty? not ] subset {\r
         { [ dup empty? ] [ 3drop ] }\r
         { [ dup length 1 = ] [ first -rot f (write-message) ] }\r
-        { [ t ] [\r
+        [\r
             [ first -rot f (write-message) ] 3keep\r
             1 tail -rot [ t (write-message) ] 2curry each\r
-        ] }\r
+        ]\r
     } cond ;\r
 \r
 : (log-message) ( msg -- )\r
index 825d58c7c2c2d43e29c369d6574f168c1a3a221e..e559ebc60d3e78eda47d94a297b0ddf17a90d65a 100755 (executable)
@@ -58,7 +58,7 @@ MACRO: match-cond ( assoc -- )
         { [ dup match-var? ] [ get ] }
         { [ dup sequence? ] [ [ replace-patterns ] map ] }
         { [ dup tuple? ] [ tuple>array replace-patterns >tuple ] }
-        { [ t ] [ ] }
+        [ ]
     } cond ;
 
 : match-replace ( object pattern1 pattern2 -- result )
index 77c7d9247dda521e994a4ac7ef3747dcb6f936ea..b3cfba8650ff810b6863fd803a120897fbf0cc3a 100755 (executable)
@@ -99,7 +99,7 @@ M: real absq sq ;
         { [ pick fp-nan? pick fp-nan? or ] [ 3drop f ] }
         { [ dup zero? ] [ drop number= ] }
         { [ dup 0 < ] [ ~rel ] }
-        { [ t ] [ ~abs ] }
+        [ ~abs ]
     } cond ;
 
 : power-of-2? ( n -- ? )
index ea7f02829dc7c85ee9110fd0c09c8b0afeaaf352..c8a21512ecb81d36098a4f765765cd1ba600f60f 100755 (executable)
@@ -55,7 +55,7 @@ TUPLE: miller-rabin-bounds ;
         { [ dup 1 <= ] [ 3drop f ] }
         { [ dup 2 = ] [ 3drop t ] }
         { [ dup even? ] [ 3drop f ] }
-        { [ t ] [ [ drop trials set t (miller-rabin) ] with-scope ] }
+        [ [ drop trials set t (miller-rabin) ] with-scope ]
     } cond ;
 
 : miller-rabin ( n -- ? ) 10 miller-rabin* ;
index eeb1b66a89f2f03e62470bfa4d85f3e88bd2b1b5..edad69fffc650b94a12a5af5c1842640cc08e894 100644 (file)
@@ -38,9 +38,8 @@ PRIVATE>
     { [ dup 2 < ] [ drop { } ] }
     { [ dup 1000003 < ]
       [ primes-under-million [ [ <=> ] binsearch 1+ 0 swap ] keep <slice> ] }
-    { [ t ]
-      [ primes-under-million 1000003 lprimes-from
-        rot [ <= ] curry lwhile list>array append ] }
+    [ primes-under-million 1000003 lprimes-from
+        rot [ <= ] curry lwhile list>array append ]
   } cond ; foldable
 
 : primes-between ( low high -- seq )
index 8f9e34b1fbedf6cd3bb7b658cb846424c6ec9504..dd6fc7dfff6014c43d473894f141130c7bf2fd25 100755 (executable)
@@ -89,7 +89,7 @@ SYMBOL: total
             { [ 2dup [ class< ] 2keep swap class< and ] [ 0 ] }
             { [ 2dup class< ] [ -1 ] }
             { [ 2dup swap class< ] [ 1 ] }
-            { [ t ] [ 0 ] }
+            [ 0 ]
         } cond 2nip
     ] 2map [ zero? not ] find nip 0 or ;
 
index ca97eab3bc8b455696e18e681f57f9f758c3663c..a809c611b5c8792ff15d4586cf9bd0d25a047589 100644 (file)
@@ -88,38 +88,38 @@ SYMBOL: SQL-TYPE-UNKNOWN
 \r
 : convert-sql-type ( number -- symbol )\r
   {\r
-    { [ dup 1 = ] [ drop SQL-CHAR ] }\r
-    { [ dup 12 = ] [ drop SQL-VARCHAR ] }\r
-    { [ dup -1 = ] [ drop SQL-LONGVARCHAR ] }\r
-    { [ dup -8 = ] [ drop SQL-WCHAR ] }\r
-    { [ dup -9 = ] [ drop SQL-WCHARVAR ] }\r
-    { [ dup -10 = ] [ drop SQL-WLONGCHARVAR ] }\r
-    { [ dup 3 = ] [ drop SQL-DECIMAL ] }\r
-    { [ dup 5 = ] [ drop SQL-SMALLINT ] }\r
-    { [ dup 2 = ] [ drop SQL-NUMERIC ] }\r
-    { [ dup 4 = ] [ drop SQL-INTEGER ] }\r
-    { [ dup 7 = ] [ drop SQL-REAL ] }\r
-    { [ dup 6 = ] [ drop SQL-FLOAT ] }\r
-    { [ dup 8 = ] [ drop SQL-DOUBLE ] }\r
-    { [ dup -7 = ] [ drop SQL-BIT ] }\r
-    { [ dup -6 = ] [ drop SQL-TINYINT ] }\r
-    { [ dup -5 = ] [ drop SQL-BIGINT ] }\r
-    { [ dup -2 = ] [ drop SQL-BINARY ] }\r
-    { [ dup -3 = ] [ drop SQL-VARBINARY ] }   \r
-    { [ dup -4 = ] [ drop SQL-LONGVARBINARY ] }\r
-    { [ dup 91 = ] [ drop SQL-TYPE-DATE ] }\r
-    { [ dup 92 = ] [ drop SQL-TYPE-TIME ] }\r
-    { [ dup 93 = ] [ drop SQL-TYPE-TIMESTAMP ] }\r
-    { [ t ] [ drop SQL-TYPE-UNKNOWN ] }\r
-  } cond ;\r
+    { 1 [ SQL-CHAR ] }\r
+    { 12  [ SQL-VARCHAR ] }\r
+    { -1  [ SQL-LONGVARCHAR ] }\r
+    { -8  [ SQL-WCHAR ] }\r
+    { -9  [ SQL-WCHARVAR ] }\r
+    { -10 [ SQL-WLONGCHARVAR ] }\r
+    { 3 [ SQL-DECIMAL ] }\r
+    { 5 [ SQL-SMALLINT ] }\r
+    { 2 [ SQL-NUMERIC ] }\r
+    { 4 [ SQL-INTEGER ] }\r
+    { 7 [ SQL-REAL ] }\r
+    { 6 [ SQL-FLOAT ] }\r
+    { 8 [ SQL-DOUBLE ] }\r
+    { -7 [ SQL-BIT ] }\r
+    { -6 [ SQL-TINYINT ] }\r
+    { -5 [ SQL-BIGINT ] }\r
+    { -2 [ SQL-BINARY ] }\r
+    { -3 [ SQL-VARBINARY ] }   \r
+    { -4 [ SQL-LONGVARBINARY ] }\r
+    { 91 [ SQL-TYPE-DATE ] }\r
+    { 92 [ SQL-TYPE-TIME ] }\r
+    { 93 [ SQL-TYPE-TIMESTAMP ] }\r
+    [ drop SQL-TYPE-UNKNOWN ]\r
+  } case ;\r
 \r
 : succeeded? ( n -- bool )\r
   #! Did the call succeed (SQL-SUCCESS or SQL-SUCCESS-WITH-INFO)\r
   {\r
-    { [ dup SQL-SUCCESS = ] [ drop t ] }\r
-    { [ dup SQL-SUCCESS-WITH-INFO = ] [ drop t ] }\r
-    { [ t ] [ drop f ] }\r
-  } cond ;  \r
+    { \ SQL-SUCCESS [ t ] }\r
+    { \ SQL-SUCCESS-WITH-INFO [ t ] }\r
+    [ drop f ]\r
+  } case ;  \r
 \r
 FUNCTION: SQLRETURN SQLAllocHandle ( SQLSMALLINT handleType, SQLHANDLE inputHandle, SQLHANDLE* outputHandlePtr ) ;\r
 FUNCTION: SQLRETURN SQLSetEnvAttr ( SQLHENV environmentHandle, SQLINTEGER attribute, SQLPOINTER valuePtr, SQLINTEGER stringLength ) ;\r
@@ -213,21 +213,21 @@ C: <column> column
 \r
 : dereference-type-pointer ( byte-array column -- object )\r
   column-type {\r
-    { [ dup SQL-CHAR = ] [ drop alien>char-string ] }\r
-    { [ dup SQL-VARCHAR = ] [ drop alien>char-string ] }\r
-    { [ dup SQL-LONGVARCHAR = ] [ drop alien>char-string ] }\r
-    { [ dup SQL-WCHAR = ] [ drop alien>char-string ] }\r
-    { [ dup SQL-WCHARVAR = ] [ drop alien>char-string ] }\r
-    { [ dup SQL-WLONGCHARVAR = ] [ drop alien>char-string ] }\r
-    { [ dup SQL-SMALLINT = ] [ drop *short ] }\r
-    { [ dup SQL-INTEGER = ] [ drop *long ] }\r
-    { [ dup SQL-REAL = ] [ drop *float ] }\r
-    { [ dup SQL-FLOAT = ] [ drop *double ] }\r
-    { [ dup SQL-DOUBLE = ] [ drop *double ] }\r
-    { [ dup SQL-TINYINT = ] [ drop *char  ] }\r
-    { [ dup SQL-BIGINT = ] [ drop *longlong ] }\r
-    { [ t ] [ nip [ "Unknown SQL Type: " % word-name % ] "" make ] }    \r
-  } cond ;\r
+    { SQL-CHAR [ alien>char-string ] }\r
+    { SQL-VARCHAR [ alien>char-string ] }\r
+    { SQL-LONGVARCHAR [ alien>char-string ] }\r
+    { SQL-WCHAR [ alien>char-string ] }\r
+    { SQL-WCHARVAR [ alien>char-string ] }\r
+    { SQL-WLONGCHARVAR [ alien>char-string ] }\r
+    { SQL-SMALLINT [ *short ] }\r
+    { SQL-INTEGER [ *long ] }\r
+    { SQL-REAL [ *float ] }\r
+    { SQL-FLOAT [ *double ] }\r
+    { SQL-DOUBLE [ *double ] }\r
+    { SQL-TINYINT [ *char  ] }\r
+    { SQL-BIGINT [ *longlong ] }\r
+    [ nip [ "Unknown SQL Type: " % word-name % ] "" make ]    \r
+  } case ;\r
 \r
 TUPLE: field value column ;\r
 \r
@@ -267,4 +267,4 @@ C: <field> field
     dup odbc-execute\r
     dup odbc-get-all-rows\r
     swap odbc-free-statement\r
-  ] keep odbc-disconnect ;
\ No newline at end of file
+  ] keep odbc-disconnect ;\r
index 2a685eccd1cd3a836f6094d6b76fab5a13b5b84b..d4ad11311fa2264f08bcfaee8c723da9234d884f 100755 (executable)
@@ -179,7 +179,7 @@ HINTS: yuv>rgb byte-array byte-array ;
     num-audio-buffers-processed {\r
         { [ over player-buffers length 1 = over zero? and ] [ drop append-new-audio-buffer t ] }\r
         { [ over player-buffers length 2 = over zero? and ] [ yield drop f ] }\r
-        { [ t ] [ fill-processed-audio-buffer t ] }\r
+        [ fill-processed-audio-buffer t ]\r
     } cond ;\r
 \r
 : start-audio ( player -- player bool )\r
@@ -284,7 +284,7 @@ HINTS: yuv>rgb byte-array byte-array ;
         decode-packet {\r
             { [ is-vorbis-packet? ] [ handle-initial-vorbis-header ] }\r
             { [ is-theora-packet? ] [ handle-initial-theora-header ] }\r
-            { [ t ]                 [ handle-initial-unknown-header ] }\r
+            [ handle-initial-unknown-header ]\r
         } cond t\r
     ] [\r
         f\r
index b8ac396c2f126355a52834ba15003f7b9442be22..f6943c1ec606709e766c53f7ce6474be6fc92509 100644 (file)
@@ -7,7 +7,7 @@ ERROR: unknown-gl-platform ;
     { [ os windows? ] [ "opengl.gl.windows" ] }
     { [ os macosx? ]  [ "opengl.gl.macosx" ] }
     { [ os unix? ] [ "opengl.gl.unix" ] }
-    { [ t ] [ unknown-gl-platform ] }
+    [ unknown-gl-platform ]
 } cond use+ >>
 IN: opengl.gl.extensions
 
index 1f5453798d283441c5741a65817c5622857abc85..a726095eb109bd225bd20c4fb4da298f1116d201 100755 (executable)
@@ -149,7 +149,7 @@ SYMBOL: node-count
                     { [ dup "intrinsics" word-prop over "if-intrinsics" word-prop or ] [ intrinsics-called ] }
                     { [ dup generic? ] [ generics-called ] }
                     { [ dup method-body? ] [ methods-called ] }
-                    { [ t ] [ words-called ] }
+                    [ words-called ]
                 } cond 1 -rot get at+
             ] [
                 drop
index a30ce648542d6bc95c7b21518bffcaf02f9c3c72..441abd928eb5bc54c36e3c6ff158dbaecc2bf47a 100644 (file)
@@ -35,20 +35,20 @@ C: <connection> connection
 
 : check-result ( result -- )
     {
-        { [ dup OCI_SUCCESS = ] [ drop ] }
-        { [ dup OCI_ERROR = ] [ err get get-oci-error ] }
-        { [ dup OCI_INVALID_HANDLE = ] [ "invalid handle" throw ] }
-        { [ t ] [ "operation failed" throw ] }
-    } cond ;
+        { \ OCI_SUCCESS [ ] }
+        { \ OCI_ERROR [ err get get-oci-error ] }
+        { \ OCI_INVALID_HANDLE [ "invalid handle" throw ] }
+        [ "operation failed" throw ]
+    } case ;
 
 : check-status ( status -- bool )
     {
-        { [ dup OCI_SUCCESS = ] [ drop t ] }
-        { [ dup OCI_ERROR = ] [ err get get-oci-error ] }
-        { [ dup OCI_INVALID_HANDLE = ] [ "invalid handle" throw ] }
-        { [ dup OCI_NO_DATA = ] [ drop f ] }
-        { [ t ] [ "operation failed" throw ] }
-    } cond ;
+        { \ OCI_SUCCESS [ t ] }
+        { \ OCI_ERROR [ err get get-oci-error ] }
+        { \ OCI_INVALID_HANDLE [ "invalid handle" throw ] }
+        { \ OCI_NO_DATA [ f ] }
+        [ "operation failed" throw ]
+    } case ;
 
 ! =========================================================
 ! Initialization and handle-allocation routines
@@ -153,19 +153,19 @@ C: <connection> connection
     >r stm get err get r> dup length swap malloc-char-string swap
     OCI_NTV_SYNTAX OCI_DEFAULT OCIStmtPrepare check-result ;
 
-: calculate-size ( type -- size object )
+: calculate-size ( type -- size )
     {
-        { [ dup SQLT_INT = ] [ "int" heap-size ] }
-        { [ dup SQLT_FLT = ] [ "float" heap-size ] }
-        { [ dup SQLT_CHR = ] [ "char" heap-size ] }
-        { [ dup SQLT_NUM = ] [ "int" heap-size 10 * ] }
-        { [ dup SQLT_STR = ] [ 64 ] }
-        { [ dup SQLT_ODT = ] [ 256 ] }
-    } cond ;
+        { \ SQLT_INT [ "int" heap-size ] }
+        { \ SQLT_FLT [ "float" heap-size ] }
+        { \ SQLT_CHR [ "char" heap-size ] }
+        { \ SQLT_NUM [ "int" heap-size 10 * ] }
+        { \ SQLT_STR [ 64 ] }
+        { \ SQLT_ODT [ 256 ] }
+    } case ;
 
 : define-by-position ( position type -- )
     >r >r stm get f <void*> err get
-    r> r> calculate-size swap >r [ "char" malloc-array dup buf set ] keep 1+
+    r> r> dup calculate-size >r [ "char" malloc-array dup buf set ] keep 1+
     r> f f f OCI_DEFAULT OCIDefineByPos check-result ;
 
 : execute-statement ( -- bool )
index fec3163e2f484077f60715bb35894191460ad557..81820e0152801d685c89bbe8353f5468049c113e 100644 (file)
@@ -60,7 +60,7 @@ USING: kernel math parser sequences combinators splitting ;
         { [ 1 over consonant-end? not ] [ drop f ] }
         { [ 2 over consonant-end? ] [ drop f ] }
         { [ 3 over consonant-end? not ] [ drop f ] }
-        { [ t ] [ "wxy" last-is? not ] }
+        [ "wxy" last-is? not ]
     } cond ;
 
 : r ( str oldsuffix newsuffix -- str )
@@ -75,7 +75,7 @@ USING: kernel math parser sequences combinators splitting ;
             { [ "ies" ?tail ] [ "i" append ] }
             { [ dup "ss" tail? ] [ ] }
             { [ "s" ?tail ] [ ] }
-            { [ t ] [ ] }
+            [ ]
         } cond
     ] when ;
 
@@ -114,11 +114,11 @@ USING: kernel math parser sequences combinators splitting ;
                 {
                     { [ "ed" ?tail ] [ -ed ] }
                     { [ "ing" ?tail ] [ -ing ] }
-                    { [ t ] [ f ] }
+                    [ f ]
                 } cond
             ] [ -ed/ing ]
         }
-        { [ t ] [ ] }
+        [ ]
     } cond ;
 
 : step1c ( str -- newstr )
@@ -149,7 +149,7 @@ USING: kernel math parser sequences combinators splitting ;
         { [ "iviti"   ?tail ] [ "iviti"   "ive"  r ] }
         { [ "biliti"  ?tail ] [ "biliti"  "ble"  r ] }
         { [ "logi"    ?tail ] [ "logi"    "log"  r ] }
-        { [ t ] [ ] }
+        [ ]
     } cond ;
 
 : step3 ( str -- newstr )
@@ -161,7 +161,7 @@ USING: kernel math parser sequences combinators splitting ;
         { [ "ical"  ?tail ] [ "ical"  "ic" r ] }
         { [ "ful"   ?tail ] [ "ful"   ""   r ] }
         { [ "ness"  ?tail ] [ "ness"  ""   r ] }
-        { [ t ] [ ] }
+        [ ]
     } cond ;
 
 : -ion ( str -- newstr )
@@ -192,7 +192,7 @@ USING: kernel math parser sequences combinators splitting ;
         { [ "ous"   ?tail ] [ ] }
         { [ "ive"   ?tail ] [ ] }
         { [ "ize"   ?tail ] [ ] }
-        { [ t ] [ ] }
+        [ ]
     } cond dup consonant-seq 1 > [ nip ] [ drop ] if ;
 
 : remove-e? ( str -- ? )
@@ -210,7 +210,7 @@ USING: kernel math parser sequences combinators splitting ;
         { [ dup peek CHAR: l = not ] [ ] }
         { [ dup length 1- over double-consonant? not ] [ ] }
         { [ dup consonant-seq 1 > ] [ butlast ] }
-        { [ t ] [ ] }
+        [ ]
     } cond ;
 
 : step5 ( str -- newstr ) remove-e ll->l ;