Comment detail
アレイのuniq (Nested Flatten)This comment is reply for 456 ether: # uniq [3; 1; 4; 1; ...(アレイのuniq). Go to thread root.
関数型ということにこだわらなければこういう手も。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | open System;;
open Array;;
let uniq xs =
let ars = create (length xs) xs.(0) in
let i = ref 1 in
for idx = 1 to (length xs)-1
do
if not (exists (fun elem -> xs.(idx) = elem) ars)
then
begin
ars.(!i) <- xs.(idx);
i := !i+1
end
else ()
done;
sub ars 0 !i;;
|





ether
#481()
[
OCaml
]
Rating0/0=0.00
Rating0/0=0.00-0+