]> gitweb.factorcode.org Git - factor.git/commitdiff
try-find is just attempt-all. oops
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 29 Jan 2010 05:28:11 +0000 (23:28 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 29 Jan 2010 05:28:11 +0000 (23:28 -0600)
basis/random/windows/windows.factor
core/continuations/continuations-docs.factor
core/continuations/continuations-tests.factor
core/continuations/continuations.factor

index a10f90ddef58e32e33291110cc4b662bc1fff651..30b169bfedc1ac841f67f138a53b70362d91b5c7 100644 (file)
@@ -59,11 +59,11 @@ M: windows-rng random-bytes* ( n tuple -- bytes )
         [ CryptGenRandom win32-error=0/f ] keep
     ] with-destructors ;
 
-ERROR: no-windows-crypto-provider ;
+ERROR: no-windows-crypto-provider error ;
 
 : try-crypto-providers ( seq -- windows-rng )
-    [ first2 <windows-rng> ] try-find drop
-    [ no-windows-crypto-provider ] unless* ;
+    [ first2 <windows-rng> ] attempt-all
+    dup windows-rng? [ no-windows-crypto-provider ] unless ;
 
 [
     {
index afe14bf5c66bbcae393633b6d5715cbaf34c4947..ac33eee2c512af8b9971ace73804f11ab1b13266 100644 (file)
@@ -48,10 +48,6 @@ $nl
     recover\r
     ignore-errors\r
 }\r
-"Word for mapping over a sequence with a quotation until an element doesn't throw an exception:"\r
-{ $subsections\r
-    try-find\r
-}\r
 "Syntax sugar for defining errors:"\r
 { $subsections POSTPONE: ERROR: }\r
 "Unhandled errors are reported in the listener and can be debugged using various tools. See " { $link "debugger" } "."\r
@@ -185,10 +181,6 @@ HELP: recover
 { $values { "try" quotation } { "recovery" { $quotation "( error -- )" } } }\r
 { $description "Calls the " { $snippet "try" } " quotation. If an exception is thrown in the dynamic extent of the " { $snippet "try" } " quotation, restores the data stack and calls the " { $snippet "recovery" } " quotation to handle the error." } ;\r
 \r
-HELP: try-find\r
-{ $values { "seq" sequence } { "try" quotation } { "result" "the first non-false, non-exception result of the quotation" } { "elt" "the first matching element, or " { $link f } } }\r
-{ $description "Applies the quotation to each element of the sequence, until the quotation outputs a true value, and attempts the next element if an exception is thrown. If the quotation ever yields a result which is not " { $link f } ", then the value is output, along with the element of the sequence which yielded this." } ;\r
-\r
 HELP: ignore-errors\r
 { $values { "quot" quotation } }\r
 { $description "Calls the quotation. If an exception is thrown in the dynamic extent of the quotation, restores the data stack and returns." } ;\r
index 5ee61f84d8e418fcf936c4b8338f4e9aecd08cf7..0d2880eddefbe7c93255e8e54607eeb82183c21f 100644 (file)
@@ -106,15 +106,3 @@ SYMBOL: error-counter
 [ { 4 } ] [ { 2 2 } [ + ] with-datastack ] unit-test\r
 \r
 [ with-datastack ] must-infer\r
-\r
-[ { t 1 } ]\r
-[ { 1 1 } [ odd? ] try-find 2array ] unit-test\r
-\r
-[ { 9 3 } ]\r
-[ { 3 3 } [ sq ] try-find 2array ] unit-test\r
-\r
-[ { f f } ]\r
-[ { 1 1 } [ even? ] try-find 2array ] unit-test\r
-\r
-[ { f f } ]\r
-[ { 1 1 } [ "error" throw ] try-find 2array ] unit-test\r
index 9feea46b84a5d6cfec3139d8c8d524417a54e0c9..d63acae8836213fbbef3ae6ad5431717f06e55fa 100644 (file)
@@ -128,9 +128,6 @@ SYMBOL: thread-error-hook
 : cleanup ( try cleanup-always cleanup-error -- )
     [ compose [ dip rethrow ] curry recover ] [ drop ] 2bi call ; inline
 
-: try-find ( seq try -- result elt )
-    [ curry [ drop f ] recover ] curry map-find ; inline
-
 ERROR: attempt-all-error ;
 
 : attempt-all ( seq quot -- obj )