I'm trying to get my head around writing (good?) Factor code. Could 
someone point me in the right direction on the snippet below? Even after 
a few rounds of cleanup, I haven't been able to make it very 
intention-revealing, mostly (maybe?) because of juggling three values on 
the stack.


USING: kernel sequences math ;
IN: coins

<PRIVATE

: make-change-with-coin ( coins cents coin -- coins cents )
[ 2dup >= ]
   [ tuck - swap tuck [ prefix ] 2dip ] while
drop ;

PRIVATE>

: change ( cents -- coins )
{ } swap
{ 25 10 5 1 } [ make-change-with-coin ] each
drop ;



( scratchpad ) 99 change .
{ 1 1 1 1 10 10 25 25 25 }

-- 
Kyle Cordes
http://kylecordes.com

------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to