Is it true? Ask Jelly!
Jelly, 3 bytes
ṭFẠ
F
flattens the input list.
ṭ
tacks on the original input list as an element, which is falsy if and only if it is empty.
Ạ
then checks if any element in the flattened list, or the original list itself, is falsy.
(Original answer)
FẠ^Ṇ
Thanks to Dennis for encouraging finding a solution matching his.
FẠ
gives 0 if the input contains a falsy value at any depth, else 1. This is what Ȧ
does, except for empty lists.
Ṇ
gives 1 if the input is a falsy value, else 0. The only falsy list is the empty list.
XOR-ing the two gives the answer.
F;WẠ
This is much in the same spirit as Dennis's F;LẠ
, but instead of using L
to put a zero in the list when the list is empty, it uses W
to put the empty list into itself (producing [[]]
), making it contain a falsy element.
Retina, 10 bytes
A`\b0
^...
Try it online!
First we remove the input if it contains a zero. The we try to match at least three characters from the beginning of the string (to ensure that the input hasn't been eliminated in the previous stage, or was only []
to begin with).
Ruby, 25 24 23 18 16 bytes
p$_!~/\D0|^..$/
Requires the -n
flag on the command line (+1 byte, -e
-> -ne
).
Try it online!
This is a full program that takes input in Ruby's canonical array format on STDIN and outputs true
or false
on STDOUT.
$_ # line of input that was read automatically (-n)
!~/ / # does not match the regex...
\D0 # a non-digit followed by a 0
| # or...
^..$ # a 2-length string (which must be [], the empty array)
p # output the result
23 byte function version:
->a{"#{a}"!~/\D0|^..$/}
This is a proc that takes one argument, the array to be tested.
Thanks to Martin Ender for a byte and to Ventero for two bytes!