You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The value of the variables after this code is:
var1 = ((1 #f #f) (2 #t #f) (3 #f #f)))
var2 = ((1 #f #f) (2 #t #f) (3 #f #f))) //notice how they both have a #t
But what I would expect the two variables to be is:
var1 = ((1 #f #f) (2 #f #f) (3 #f #f)))
var2 = ((1 #f #f) (2 #t #f) (3 #f #f))) //notice how only var2 has a #t
So basically the two variables get linked, preventing me from making more complex code.
Is this intended and is there a workaround or does this need fixing?
The text was updated successfully, but these errors were encountered:
It currently has the correct behaviour. Var2 gets bound to the value of var1. That is a list. So var1 and var2 are bith bound to the same cons cell ie the same list. So if you modify the list it's the same list for both.
But you should try to avoid mutating lists. Or anything, really.
When using this code:
The value of the variables after this code is:
var1 = ((1 #f #f) (2 #t #f) (3 #f #f)))
var2 = ((1 #f #f) (2 #t #f) (3 #f #f))) //notice how they both have a #t
But what I would expect the two variables to be is:
var1 = ((1 #f #f) (2 #f #f) (3 #f #f)))
var2 = ((1 #f #f) (2 #t #f) (3 #f #f))) //notice how only var2 has a #t
So basically the two variables get linked, preventing me from making more complex code.
Is this intended and is there a workaround or does this need fixing?
The text was updated successfully, but these errors were encountered: