diff --git a/Kernel/setSubstitutionSystem$cpp.m b/Kernel/setSubstitutionSystem$cpp.m index ea73b25c9..0a09b6ea5 100644 --- a/Kernel/setSubstitutionSystem$cpp.m +++ b/Kernel/setSubstitutionSystem$cpp.m @@ -77,8 +77,8 @@ sublists. *) (* This format is used to pass both rules and set data into libSetReplace over LibraryLink *) -encodeNestedLists[list_List] := - {list} //. {{l___, List[args___], r___} :> {l, Length[{args}], args, r}} +encodeNestedLists[list_List] := Flatten @ {Length @ list, encodeNestedLists /@ list} +encodeNestedLists[arg_] := arg (* This is the reverse, used to decode set data (a list of expressions) from libSetReplace *)