 M: amb-failure summary drop "Backtracking failure" ;
 
 : fail ( -- )
-    failure get [ continue ]
-    [ amb-failure ] if* ;
+    failure get [ continue ] [ amb-failure ] if* ;
 
 : require ( ? -- )
     [ fail ] unless ;
 
 MACRO: checkpoint ( quot -- quot' )
-    '[ failure get _
-       '[ '[ failure set _ continue ] callcc0
-          _ failure set @ ] callcc0 ] ;
+    '[
+        failure get _ '[
+            '[ failure set _ continue ] callcc0
+            _ failure set @
+        ] callcc0
+    ] ;
 
 : number-from ( from -- from+n )
     [ 1 + number-from ] checkpoint ;

    [ amb-integer ] [ nth ] bi ;

: amb ( seq -- elt )
    [ fail f ]
    [ unsafe-amb ] if-empty ; inline

MACRO: amb-execute ( seq -- quot )
    [ length 1 - ] [ <enum> [ 1quotation ] assoc-map ] bi

! Copyright (C) 2008 William Schlieper
! See http://factorcode.org/license.txt for BSD license.

USING: assocs combinators continuations fry kernel macros math
namespaces quotations sequences summary ;

IN: backtrack

