(* zadatak pod a *) fun velika nil = 0 | velika(h::t) = if(ord(h)>=65 andalso ord(h)<=90) then 1+velika(t) else velika(t); fun cifre nil = nil | cifre(h::t) = if(ord(h)>=48 andalso ord(h)<=57) then [h]@cifre(t) else cifre(t); fun cjelobrlista nil = nil | cjelobrlista(h::t) = [(ord(h)-48)]@cjelobrlista(t); (* od char liste cifara, pravi int listu *) fun ubaci(x,nil) = [x] | ubaci(x,h::t) = if x>h then x::h::t else h::ubaci(x,t); fun sort nil = nil | sort(h::t) = ubaci(h, sort t); fun f1 x = [velika(explode x)]@[hd(sort(cjelobrlista(cifre(explode x))))]; (* zadatak pod b *) fun lista(0)=nil | lista(n)=lista(n-1)@[n]; fun dijeli(nil,x)=nil | dijeli(h::t,x) = if (x mod h = 0) then dijeli(t,x)@[h] else dijeli(t,x); fun provjeri x = dijeli(lista(x),x); fun prost x = if length(provjeri(x))=2 then true else false; fun ispitaj (x,t) = if(prost t) then (if prost(x-t) then t else ispitaj(x,t-1)) else ispitaj(x,t-1); fun f2 x = [ispitaj(x,x)]@[x-ispitaj(x,x)];