Slava Pestov wrote:
> Try using make and , instead of passing an accumulator around on the stack.
Thank you, that is a large improvement, implemented below.
I am still unhappy with the obtuseness of "tuck - swap", is there a
better way to do that?
USING: kernel sequences math make ;
IN: coins
: change ( amount -- coins )
[
{ 25 10 5 1 } [
[ 2dup >= ] [ tuck - swap dup , ] while
drop ] each
] { } make nip ;
Daniel Ehrenberg wrote:
> : change ( amount -- coins )
> { 25 10 5 1 }
> [ [ /mod swap ] map nip ] keep
> [ <repetition> ] 2map concat ;
This is comprised substantially of Factor words I don't yet know :-) but
will learn.
--
Kyle Cordes
http://kylecordes.com
------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk