William James
12/1/2015 5:19:00 PM
Pascal Costanza wrote:
> > can someone tell me where is the guarantee that
> > set-difference returns a newly allocated list?
> > From my casual reading it appears to me that
> > set-difference is allowed to return one of the
> > original lists, or a cons therein.
> >
> > Am I reading this correctly that set-difference
> > may not allocate a new list in some situations?
>
> If you need such a guarantee, you need to sprinkle some
> calls to copy-list in the right places.
Ocaml:
module SS = Set.Make(String);;
let s1 = SS.of_list ["a";"b";"c";"d";"e";"f"];;
let s2 = SS.of_list ["a";"d"];;
SS.diff s1 s2 |> SS.iter print_endline ;;
b
c
e
f
--
If the Union was formed by the accession of States, then the
Union may be dissolved by the secession of States.
--- Daniel Webster, U.S. Senate, February 15, 1833