- or download this
fun intf base next 0 = base
...
(iota (x div c)))
end;
- or download this
datatype 'a option = Solution of 'a | Nothing;
- 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)
- 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;
- 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;