Help for this page

Select Code to Download


  1. or download this
    
    fun intf base next 0 = base
    ...
                         (iota (x div c)))
    end;
    
  2. or download this
      datatype 'a option = Solution of 'a | Nothing;
    
  3. or download this
      fun sflat ls = foldr (fn (Solution x, _) => Solution x
                             | (Nothing,v) => v) 
                           Nothing ls;
      fun smap _ Nothing = Nothing | smap f (Solution x) = Solution (f x)
    
  4. or download this
    local
      fun repeat x = intf [] (fn (_,ls) => x::ls)
    ...
             sflat (map (fn n => smap (fn x => (repeat c n) @ x) (change1 
    +cs (x - n*c)))
                         (iota (x div c)))
    end;
    
  5. or download this
    local val addup = foldr (fn (a,b) => a+b) 0
    in
    ...
             addup (map (fn n => countchange cs (x - n*c))
                        (iota (x div c)))
    end;