« first day (224 days earlier)      last day (377 days later) » 

1:50 PM
Is there some way of writing
a <- 1 ; b <- a <- 2
which ends with a=2 and b=1?
(Apart from the obvious a <- 1; b <- a; a<- 2: I'd like to avoid the extra a.)
 
 
1 hour later…
3:09 PM
@RobinRyder if you're not set on names, you could just use T in place of b and set a=2 separately but I'm not sure how you're trying to use it
 
@Giuseppe a and b will be components of a vector, so it will be more like
(some value has been defined for m[1] earlier in a loop)
m[2] <- m[1]; m[1] <- 0
and I'd like not having to type m[1] twice
 
3:26 PM
@RobinRyder you can't just do m=c(0,m)? you could link to a TIO of whatever problem you're working on
or else m=c(0,m[-1])
er, I think that should be m=c(0,m[-2]) but you get the idea
 
 
1 hour later…
4:37 PM
Thanks. I think the best I can do in my situation is
m[2:1]=m[1]*1:0
It's for the new chess problem. I'll post a link in a few minutes.
 
4:52 PM
Here is the link: https://codegolf.stackexchange.com/a/182543/86301
I was looking to improve on p[m[2:1]]=p[m[1]]*1:0
 
@RobinRyder ah, I see. Yeah you could do p[m[2:1]]=p[m]*1:0 instead since it'll just discard the remainder of p[m], with a warning. 3 whole bytes!
 
5:20 PM
@Giuseppe Thanks! I like that solution.
 

« first day (224 days earlier)      last day (377 days later) »