(* zadatak pod a *) fun stepen(a,0)=1 | stepen(a,b) = a*stepen(a,b-1); fun cifre nil = nil | cifre(h::t) = if(ord(h)>=48 andalso ord(h)<=57) then [h]@cifre(t) else cifre(t); fun broj(l,0) = 0 | broj(h::t,brojac) = (ord(h)-ord(#"0"))*stepen(10,brojac-1)+broj(t,brojac-1); fun f1 s = broj(cifre(explode s),length(cifre(explode s))); (* zadatak pod b *) fun ubaci(x,nil) = [x] | ubaci(x,h::t) = if f1(x)>f1(h) then x::h::t else h::ubaci(x,t); fun sort nil = nil | sort(h::t) = ubaci(h, sort t); fun f2 l = sort l;