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
It would be nice if (set (some ...) ...) worked like that, but it simply doesn't. Recall the definition:
(def some (f xs)
(if (no xs) nil
(f (car xs)) xs
(some f (cdr xs))))
Note in particular the xs being returned in the second branch. That's a parameter, so it's a lexical variable. That's the thing that gets modified by set later; it happens (which is why there's no error) but it's not visible.
Seems not only is this one busted, but maybe we also don't have a test for something like this.
It's not busted, it turns out. But I agree with OP that a test for this would be better. Going to rename the issue to reflect this.
The originally-expected behavior for some feels like it could have been useful. I wonder if it can be implemented to do that.
masak
changed the title
Trouble with '(set (some ...) ...)'
Add a test to capture the fact that 'some' returns a lexical variable and can't be used for modifying the tail of the input list
Oct 9, 2022
Expected that last one to be
(1 2 10 20 30)
.Seems not only is this one busted, but maybe we also don't have a test for something like this.
The text was updated successfully, but these errors were encountered: