How to create assignments to OverVector programmatically

I wish to write a function that accepts two lists. The 1st argument is a list of lists, holding the components of a several vectors. Ex.: comp = {{a, b}, {c, d}}. The 2nd argument would be a list of vector names, as in names = {v1, v2}.

The function would have the form myVectors[comp_List, names_List], and after a call of myVector[comp, names] (values as above), OverVector[v1] and OverVector[v2] should be symbols, with {a, b} and {c, d} assigned to them.

The problem I have is in doing programmatic assignment of the vectors {a, b} and {c, d} to OverVector[v1] and OverVector[v2], respectively.

This is what I tried so far, without success (example for the assignment to OverVector[v2]):

Needs["Notation"]

Symbolize[ParsedBoxWrapper[OverscriptBox[a_, "\[RightVector]"]]]

names = {v1, v2}
name = ToString[names[[2]], InputForm]

ToExpression[
ToString[OverscriptBox[name, "\[RightVector]"], StandardForm] <>
"=" <> "{c,d}"]


The result is an error message:

Set::write: Tag OverscriptBox in OverscriptBox[v2,[RightVector]] is Protected. >>

What should I do to make assignment of {c, d} to OverVector[v2] and {a, b} to OverVector[v1] work?

• Try Thread, maybe that will help? – Wjx Jun 28 '16 at 8:32
• This is caused by the notation package. If you insist on it, I am afraid you can only make assignments using palettes. Assigning to symbol v2\[UnderBracket]Overscript\[UnderBracket]RightVector looks the closest, but only works after initial assignment. – happy fish Jun 28 '16 at 9:06
• What exactly are palettes? – Dieter Ernst Jun 29 '16 at 10:33

I am a little uncertain about exactly the behaviour that you hope to achieve. However, if Mathematica complains that something is protected you have the option of Unprotecting it. In this case, it is unlikely you are going to break any fundamental functionality (Unprotect elsewhere at your own risk!)

Needs["Notation"]
Symbolize[ParsedBoxWrapper[OverscriptBox[a_, "\[RightVector]"]]]
Unprotect[OverscriptBox];


lets you make assignments to variables that are shown as if OverVectored.

• Ok.Thanks. I wonder what sense does it make, to be able to create such symbols, and not be able to do assignements to them. Mathematica should be more liniant on this point and unprotect such symbols authomatically at the point of definition of the new notation. How else should I know for certain, that I do not damage functionalities when unprotecting all other OverscriptBoxes? – Dieter Ernst Jun 29 '16 at 10:31

The following does what you say you want myVector to do, but I'm not sure that's what you really want, since you're playing with the "Notation" package. But maybe it is.

Function:

myVectors[comp_List, names_List] :=
MapThread[Function[{vec, name}, Set[OverVector[name], vec]], {comp, names}];


Example:

myVectors[{{a, b}, {c, d}}, {v1, v2}]
(*  {{a, b}, {c, d}}  *)


Check:

OverVector[v1]
OverVector[v2]
(*
{a, b}
{c, d}
*)
`

Also, using 2D input: