I have an example of how to permanently store a variable with Set.
InitializationValue[myvar, "Local"] = 42
Initialize[myvar];
Is there a way to generalize this to SetDelayed? I want to store the following definition permanently but I’m not sure how to do it.
Unprotect[UnsortedComplement];
ClearAll[UnsortedComplement]
UnsortedComplement[alist_, del___, opt : OptionsPattern[]] :=
Select[alist, Union[{#1}, Union[del], opt] =!= Union[del, opt] & ]
Options[UnsortedComplement] = {SameTest -> Automatic};
Protect[UnsortedComplement];
Would this be the solution, where UnsortedComplement is replaced with InitializationValue[UnsortedComplement, “Local”] everywhere?
Unprotect[InitializationValue[UnsortedComplement, "Local"]];
ClearAll[InitializationValue[UnsortedComplement, "Local"]]
InitializationValue[UnsortedComplement, "Local"][alist_, del___,
opt : OptionsPattern[]] :=
Select[alist, Union[{#1}, Union[del], opt] =!= Union[del, opt] & ]
Options[InitializationValue[UnsortedComplement,
"Local"]] = {SameTest -> Automatic};
Protect[InitializationValue[UnsortedComplement, "Local"]];
Initialize[UnsortedComplement]
There is a helpful function PersistResourceFunction that can help. I’ve also tried using PacletizeResourceFunction. I tried building a paclet but Mathematica 13.3 froze. I then tried Wolfram Desktop 13.2, but it froze when I tried to build the paclet and I had to force the programs to close with Task Manager.
Since the paclet didn’t work, I’m going to try Local as an alternative plan to paclets.
The paclet finished building successfully in Wolfram Desktop 13.2. Now it’s freezing again.
I don’t want to evaluate the code because I don’t know whats it doing and it has a side effect that I’m not sure how to undo.
I think the solution is CloudSave.