function floor n if n < 0 then return (trunc(n) - 1) else return trunc(n) end if end floor function median2 x local n, m set itemdelimiter to comma sort items of x ascending numeric put the number of items of x into n put floor(n / 2) into m if n mod 2 is 0 then return (item m of x + item (m + 1) of x) / 2 else return item (m + 1) of x end if end median2 returns the same as the built-in median, viz. put median2("4.1,5.6,7.2,1.7,9.3,4.4,3.2") & "," & median2("4.1,7.2,1.7,9.3,4.4,3.2") 4.4,4.25