Timeline for Determine if an Array contains something other than 2
Current License: CC BY-SA 3.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 16, 2017 at 6:53 | comment | added | JAD | @Giuseppe I think this answer is pretty clear, and has a lot more upvotes than the other answers: codegolf.meta.stackexchange.com/a/2194/59530 | |
May 15, 2017 at 19:48 | comment | added | Giuseppe | well, there's still not a consensus on meta, but codegolf.meta.stackexchange.com/a/2192/67312 | |
May 15, 2017 at 19:06 | comment | added | BLT | @JarkoDubbeldam I did a few months ago: codegolf.stackexchange.com/a/111578/62105 | |
May 15, 2017 at 19:05 | comment | added | JAD | @BLT maybe add it here: codegolf.stackexchange.com/questions/4024/… ;) | |
May 15, 2017 at 19:04 | comment | added | JAD |
@BLT, still very nice. Makes any answer using apply with an anonymous function that bit shorter.
|
|
May 15, 2017 at 19:03 | comment | added | BLT |
@JarkoDubbeldam it tends to get confused for more complex functions but for simple ones, it infers the arguments so you don't have to declare them (or write function ). If only the package name were shorter...
|
|
May 15, 2017 at 18:53 | comment | added | JAD | @BLT that's codegolf magic, imma check that out. | |
May 15, 2017 at 18:53 | comment | added | JAD |
@Giuseppe Not sure if TRUE counts as falsey though :/
|
|
May 15, 2017 at 16:41 | comment | added | Giuseppe |
or you could also say any(unlist(x)-2) which returns a consistent TRUE if there is a non-2 value in the flattened array and a consistent FALSE if all the values are 2 ...
|
|
May 15, 2017 at 15:29 | comment | added | Giuseppe |
this is the same length as all(unlist(x)==2) as well.
|
|
May 15, 2017 at 14:36 | comment | added | BLT |
pryr::f(!any(unlist(x)-2)) saves a couple of bytes.
|
|
May 15, 2017 at 14:17 | history | edited | JAD | CC BY-SA 3.0 |
deleted 2 characters in body
|
May 15, 2017 at 9:36 | history | answered | JAD | CC BY-SA 3.0 |