Transferring DownValues
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a code in which I define something like this:
cc[1, 2] = 1;
cc[2, 6] = 12;
cc[3, 7] = 3;
After some manipulation I define a sort of temporary variable related to cc
:
cctemp[1, 2] = 13;
cctemp[2, 6] = 8;
cctemp[3, 7] = 4;
cctemp[1, 9] = 87;
There are new and old indices.
Now in my code i wanna replace cc
with cctemp
.
I can do the trivial assignment and i can use a Do
for the substitution but its not the best. How could I realize the assignment ?
(Ps maybe something like Activate @ Inactive
....)
Thank you
symbolic assignment built-in-symbols
add a comment |Â
up vote
1
down vote
favorite
I have a code in which I define something like this:
cc[1, 2] = 1;
cc[2, 6] = 12;
cc[3, 7] = 3;
After some manipulation I define a sort of temporary variable related to cc
:
cctemp[1, 2] = 13;
cctemp[2, 6] = 8;
cctemp[3, 7] = 4;
cctemp[1, 9] = 87;
There are new and old indices.
Now in my code i wanna replace cc
with cctemp
.
I can do the trivial assignment and i can use a Do
for the substitution but its not the best. How could I realize the assignment ?
(Ps maybe something like Activate @ Inactive
....)
Thank you
symbolic assignment built-in-symbols
2
(1)List
is in the title, but it looks like you are assigningDownValues
rather than makingcc
a list. Do you meancc[[1, 2]]
rather thancc[1, 2]
, etc.? (2) Why can't you just docc[1, 2] = cctemp[1, 2]
(orcc[[1,2]] = cctemp[[1, 2]]
?
â march
1 hour ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a code in which I define something like this:
cc[1, 2] = 1;
cc[2, 6] = 12;
cc[3, 7] = 3;
After some manipulation I define a sort of temporary variable related to cc
:
cctemp[1, 2] = 13;
cctemp[2, 6] = 8;
cctemp[3, 7] = 4;
cctemp[1, 9] = 87;
There are new and old indices.
Now in my code i wanna replace cc
with cctemp
.
I can do the trivial assignment and i can use a Do
for the substitution but its not the best. How could I realize the assignment ?
(Ps maybe something like Activate @ Inactive
....)
Thank you
symbolic assignment built-in-symbols
I have a code in which I define something like this:
cc[1, 2] = 1;
cc[2, 6] = 12;
cc[3, 7] = 3;
After some manipulation I define a sort of temporary variable related to cc
:
cctemp[1, 2] = 13;
cctemp[2, 6] = 8;
cctemp[3, 7] = 4;
cctemp[1, 9] = 87;
There are new and old indices.
Now in my code i wanna replace cc
with cctemp
.
I can do the trivial assignment and i can use a Do
for the substitution but its not the best. How could I realize the assignment ?
(Ps maybe something like Activate @ Inactive
....)
Thank you
symbolic assignment built-in-symbols
symbolic assignment built-in-symbols
edited 35 mins ago
Carl Woll
61.1k280157
61.1k280157
asked 1 hour ago
siderius
365
365
2
(1)List
is in the title, but it looks like you are assigningDownValues
rather than makingcc
a list. Do you meancc[[1, 2]]
rather thancc[1, 2]
, etc.? (2) Why can't you just docc[1, 2] = cctemp[1, 2]
(orcc[[1,2]] = cctemp[[1, 2]]
?
â march
1 hour ago
add a comment |Â
2
(1)List
is in the title, but it looks like you are assigningDownValues
rather than makingcc
a list. Do you meancc[[1, 2]]
rather thancc[1, 2]
, etc.? (2) Why can't you just docc[1, 2] = cctemp[1, 2]
(orcc[[1,2]] = cctemp[[1, 2]]
?
â march
1 hour ago
2
2
(1)
List
is in the title, but it looks like you are assigning DownValues
rather than making cc
a list. Do you mean cc[[1, 2]]
rather than cc[1, 2]
, etc.? (2) Why can't you just do cc[1, 2] = cctemp[1, 2]
(or cc[[1,2]] = cctemp[[1, 2]]
?â march
1 hour ago
(1)
List
is in the title, but it looks like you are assigning DownValues
rather than making cc
a list. Do you mean cc[[1, 2]]
rather than cc[1, 2]
, etc.? (2) Why can't you just do cc[1, 2] = cctemp[1, 2]
(or cc[[1,2]] = cctemp[[1, 2]]
?â march
1 hour ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
DownValues[cc] = DownValues[cctemp] /. cctemp -> cc;
cc[1, 9]
87
cc[1, 2]
13
If cc
has some assignments that are not overridden by the assignments in cctemp
you can use
DownValues[cc] = DeleteDuplicatesBy[
Join[DownValues[cctemp], DownValues[cc]] /. cctemp -> cc, #[[1,1]]&]
add a comment |Â
up vote
3
down vote
You can make use of the undocumented Language`ExtendedDefinition
function that underlies the Wolfram Cloud. Suppose:
cctemp[1,2] = 13;
cctemp[2,6] = 8;
cctemp[3,7] = 4;
cctemp[1,9] = 87;
Then:
Language`ExtendedDefiniition[cc] = Language`ExtendedDefinition[cctemp] /. cctemp -> cc;
Finally:
DownValues[cc]
HoldPattern[cc[1, 2]] :> 13, HoldPattern[cc[1, 9]] :> 87,
HoldPattern[cc[2, 6]] :> 8, HoldPattern[cc[3, 7]] :> 4
ok thank you for the answer; just two things because i want to learn: 1) where can i find the package of this function 2) why should i prefer this way over the answer of kglr ?
â siderius
55 mins ago
@siderius There is no package, the function is built-in. UsingLanguage`ExtendedDefinition
transfers UpValues, DownValues, FormatValues, etc. If all you care about are DownValues, then using DownValues instead is better.
â Carl Woll
42 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
DownValues[cc] = DownValues[cctemp] /. cctemp -> cc;
cc[1, 9]
87
cc[1, 2]
13
If cc
has some assignments that are not overridden by the assignments in cctemp
you can use
DownValues[cc] = DeleteDuplicatesBy[
Join[DownValues[cctemp], DownValues[cc]] /. cctemp -> cc, #[[1,1]]&]
add a comment |Â
up vote
2
down vote
accepted
DownValues[cc] = DownValues[cctemp] /. cctemp -> cc;
cc[1, 9]
87
cc[1, 2]
13
If cc
has some assignments that are not overridden by the assignments in cctemp
you can use
DownValues[cc] = DeleteDuplicatesBy[
Join[DownValues[cctemp], DownValues[cc]] /. cctemp -> cc, #[[1,1]]&]
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
DownValues[cc] = DownValues[cctemp] /. cctemp -> cc;
cc[1, 9]
87
cc[1, 2]
13
If cc
has some assignments that are not overridden by the assignments in cctemp
you can use
DownValues[cc] = DeleteDuplicatesBy[
Join[DownValues[cctemp], DownValues[cc]] /. cctemp -> cc, #[[1,1]]&]
DownValues[cc] = DownValues[cctemp] /. cctemp -> cc;
cc[1, 9]
87
cc[1, 2]
13
If cc
has some assignments that are not overridden by the assignments in cctemp
you can use
DownValues[cc] = DeleteDuplicatesBy[
Join[DownValues[cctemp], DownValues[cc]] /. cctemp -> cc, #[[1,1]]&]
edited 38 mins ago
answered 1 hour ago
kglr
166k8188388
166k8188388
add a comment |Â
add a comment |Â
up vote
3
down vote
You can make use of the undocumented Language`ExtendedDefinition
function that underlies the Wolfram Cloud. Suppose:
cctemp[1,2] = 13;
cctemp[2,6] = 8;
cctemp[3,7] = 4;
cctemp[1,9] = 87;
Then:
Language`ExtendedDefiniition[cc] = Language`ExtendedDefinition[cctemp] /. cctemp -> cc;
Finally:
DownValues[cc]
HoldPattern[cc[1, 2]] :> 13, HoldPattern[cc[1, 9]] :> 87,
HoldPattern[cc[2, 6]] :> 8, HoldPattern[cc[3, 7]] :> 4
ok thank you for the answer; just two things because i want to learn: 1) where can i find the package of this function 2) why should i prefer this way over the answer of kglr ?
â siderius
55 mins ago
@siderius There is no package, the function is built-in. UsingLanguage`ExtendedDefinition
transfers UpValues, DownValues, FormatValues, etc. If all you care about are DownValues, then using DownValues instead is better.
â Carl Woll
42 mins ago
add a comment |Â
up vote
3
down vote
You can make use of the undocumented Language`ExtendedDefinition
function that underlies the Wolfram Cloud. Suppose:
cctemp[1,2] = 13;
cctemp[2,6] = 8;
cctemp[3,7] = 4;
cctemp[1,9] = 87;
Then:
Language`ExtendedDefiniition[cc] = Language`ExtendedDefinition[cctemp] /. cctemp -> cc;
Finally:
DownValues[cc]
HoldPattern[cc[1, 2]] :> 13, HoldPattern[cc[1, 9]] :> 87,
HoldPattern[cc[2, 6]] :> 8, HoldPattern[cc[3, 7]] :> 4
ok thank you for the answer; just two things because i want to learn: 1) where can i find the package of this function 2) why should i prefer this way over the answer of kglr ?
â siderius
55 mins ago
@siderius There is no package, the function is built-in. UsingLanguage`ExtendedDefinition
transfers UpValues, DownValues, FormatValues, etc. If all you care about are DownValues, then using DownValues instead is better.
â Carl Woll
42 mins ago
add a comment |Â
up vote
3
down vote
up vote
3
down vote
You can make use of the undocumented Language`ExtendedDefinition
function that underlies the Wolfram Cloud. Suppose:
cctemp[1,2] = 13;
cctemp[2,6] = 8;
cctemp[3,7] = 4;
cctemp[1,9] = 87;
Then:
Language`ExtendedDefiniition[cc] = Language`ExtendedDefinition[cctemp] /. cctemp -> cc;
Finally:
DownValues[cc]
HoldPattern[cc[1, 2]] :> 13, HoldPattern[cc[1, 9]] :> 87,
HoldPattern[cc[2, 6]] :> 8, HoldPattern[cc[3, 7]] :> 4
You can make use of the undocumented Language`ExtendedDefinition
function that underlies the Wolfram Cloud. Suppose:
cctemp[1,2] = 13;
cctemp[2,6] = 8;
cctemp[3,7] = 4;
cctemp[1,9] = 87;
Then:
Language`ExtendedDefiniition[cc] = Language`ExtendedDefinition[cctemp] /. cctemp -> cc;
Finally:
DownValues[cc]
HoldPattern[cc[1, 2]] :> 13, HoldPattern[cc[1, 9]] :> 87,
HoldPattern[cc[2, 6]] :> 8, HoldPattern[cc[3, 7]] :> 4
answered 1 hour ago
Carl Woll
61.1k280157
61.1k280157
ok thank you for the answer; just two things because i want to learn: 1) where can i find the package of this function 2) why should i prefer this way over the answer of kglr ?
â siderius
55 mins ago
@siderius There is no package, the function is built-in. UsingLanguage`ExtendedDefinition
transfers UpValues, DownValues, FormatValues, etc. If all you care about are DownValues, then using DownValues instead is better.
â Carl Woll
42 mins ago
add a comment |Â
ok thank you for the answer; just two things because i want to learn: 1) where can i find the package of this function 2) why should i prefer this way over the answer of kglr ?
â siderius
55 mins ago
@siderius There is no package, the function is built-in. UsingLanguage`ExtendedDefinition
transfers UpValues, DownValues, FormatValues, etc. If all you care about are DownValues, then using DownValues instead is better.
â Carl Woll
42 mins ago
ok thank you for the answer; just two things because i want to learn: 1) where can i find the package of this function 2) why should i prefer this way over the answer of kglr ?
â siderius
55 mins ago
ok thank you for the answer; just two things because i want to learn: 1) where can i find the package of this function 2) why should i prefer this way over the answer of kglr ?
â siderius
55 mins ago
@siderius There is no package, the function is built-in. Using
Language`ExtendedDefinition
transfers UpValues, DownValues, FormatValues, etc. If all you care about are DownValues, then using DownValues instead is better.â Carl Woll
42 mins ago
@siderius There is no package, the function is built-in. Using
Language`ExtendedDefinition
transfers UpValues, DownValues, FormatValues, etc. If all you care about are DownValues, then using DownValues instead is better.â Carl Woll
42 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184046%2ftransferring-downvalues%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
(1)
List
is in the title, but it looks like you are assigningDownValues
rather than makingcc
a list. Do you meancc[[1, 2]]
rather thancc[1, 2]
, etc.? (2) Why can't you just docc[1, 2] = cctemp[1, 2]
(orcc[[1,2]] = cctemp[[1, 2]]
?â march
1 hour ago