Hello! I found a perfect task to learn the `backtrack` vocab, and have successfully solved the problem (although the help system could use some example code). The only question I have left is why can't I compile the vocab below. I get the error that says "Cannot apply “unsafe-amb” to a run-time computed value" in the `solve` word. It works perfectly well in the listener, so why can't it work in a vocab?
Could someone point out the reason for the error? Which part of the quotation is run-time computed? I have inlined everything I could, but it didn't help. ``` ! Copyright (C) 2017 Alexander Ilin. ! See http://factorcode.org/license.txt for BSD license. USING: arrays backtrack combinators.short-circuit infix kernel locals math math.functions prettyprint scratchpad sequences sequences.private sets ; IN: andrew-task ! The task is to find digits A, B, C, D, E, and F, such that: ! all digits are 1..9, ! all of the digits are different, ! D < E < F, ! ABC*D*EE*FFF = n^2, where n is an integer. ALIAS: 0? zero? : last3 ( seq -- X Y Z ) unclip-last [ unclip-last [ last ] dip ] dip ; inline : 6array ( A B C D E F -- {ABCDEF} ) 4array swap prefix swap prefix ; inline : check-success ( {ABCDEF} -- ) { [ [ 0? ] count 0? ] [ duplicates empty? ] [ last3 [| D E F | D E < E F < and ] call ] [ [ first3 ] [ last3 ] bi [| A B C D E F | [infix A * 100 + B * 10 + C infix] :> ABC 11 E * :> EE 111 F * :> FFF { ABC D EE FFF } product :> prod prod sqrt >integer dup * prod = ] call ] } 1&& must-be-true ; inline : solve ( -- ) [ 10 <iota> amb 10 <iota> amb 10 <iota> amb 10 <iota> amb 10 <iota> amb 10 <iota> amb 6array dup check-success . ] amb-all ; MAIN: solve ``` ---=====--- Александр ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk