many thanks > On 29 Jul 2015, at 12:04, Björn Lindqvist <bjou...@gmail.com> wrote: > > Georg solved your problem, but in the future you can easily use > Factors introspection to see why it complains about stack effects. For > example, the first quotation given to the inner if is [ 0 ] and you > can infer its stack effect: > > IN: scratchpad [ 0 ] infer. > ( -- x ) > > Then because the two quotations given to if must have the same stack > effect, the second quotation must also have ( -- x ) which you can > check like this: > > ! Needs to be declared because you are using locals > IN: scratchpad SYMBOLS: amount coins cc denominations ; > IN: scratchpad [ amount coins 1 - cc amount coins denominations at* > drop - coins cc + ] infer. > ( -- x x x x x ) > > Or you can manually count the stack delta. Local variables and numbers > are +1, binary operations and drop -1 and at* is +/- 0: > +1 +1 +1 -1 +1 +1 +1 +1 0 -1 -1 +1 +1 -1 > [ amount coins 1 - cc amount coins denominations at* drop - coins cc + ] > > 1 + 1 + 1 - 1 + 1 + 1 + 1 + 1 + 0 - 1 - 1 + 1 + 1 - 1 = +5 > > 2015-07-29 9:44 GMT+02:00 Iain Gray <iaing...@ednet.co.uk>: >> why do I get the following error? >> >> Stack effect declaration is wrong >> inferred ( x x x -- x x ) >> declared ( amount coins -- ways ) >> >> from this lexical variable >> >> :: cc ( amount coins -- ways ) >> 0 amount = [ 1 ] >> [ 0 < amount 0 coins = or [ 0 ] >> [ amount coins 1 - cc >> amount coins denominations at* drop - coins cc + ] >> if ] >> if ; >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Factor-talk mailing list >> Factor-talk@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/factor-talk > > > > -- > mvh/best regards Björn Lindqvist > > ------------------------------------------------------------------------------ > _______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk
------------------------------------------------------------------------------ _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk