Zumkeller numbers: Difference between revisions

m
(→‎{{header|Swift}}: + Standard ML)
Line 3,047:
 
=={{header|Standard ML}}==
Works with smlnj
<lang Standard ML>
val divisors = fn n =>
Line 3,057 ⟶ 3,056:
divr (n,[],1)
end;
 
 
val subsetSums = fn M => fn input =>
let
val getnrs = fn (v,x) => (* out: list of numbers: index where v is true + x *)
let
val rec runthr = fn (v,i,x,lst)=> if i>=M then (v,i,x,lst) else runthr (v,i+1,x,if Vector.sub(v,i) then (i+x)::lst else lst) ;
Line 3,070:
let
val rec upd = fn (v,i,[]) => (v,i,[])
| (v,i,h::t) => upd (if h<=M then Vector.update (v,h,true) else v,i+1,t) ;
in
#1 (upd (v,0,nrs))
Line 3,082:
 
end;
 
 
val rec Zumkeller = fn n =>
Line 3,125 ⟶ 3,126:
 
</lang>
 
 
 
=={{header|Swift}}==
Anonymous user