fun threeWay(L) = let val (L0,M) = List.partition (fn x => x mod 3 = 0) L; val (L1,L2) = List.partition (fn x => x mod 3 = 1) M in (L0,L1,L2) end;