(* same input, same type of output for all functions. fixed number of functions *) fun demux3_sameinput (P, [c1, c2, c3], (f1, f2, default), r) = if P(c1) then f1(r) else if P(c2) then f2(r) else default(r); (* same type of input, same type of output for all functions. fixed number of functions *) fun demux3_sametypeinput (P, [c1, c2, c3], (f1, f2, default), [r1, r2, r3]) = if P(c1) then f1(r1) else if P(c2) then f2(r2) else default(r3); (* different input, same type of output for all functions. fixed number of functions *) fun demux3 (P, [c1, c2, c3], (f1, f2, default), (r1, r2, r3)) = if P(c1) then f1(r1) else if P(c2) then f2(r2) else default(r3);