Axiom, 280 bytes
w(x:Union(List(Any),NNI)):Boolean==(x case List(Any)=>(g:List(Any):=x;leaf? g=>return true;for i in g repeat(q:=w(i);q=false=>return false);return true);r:NNI:=x;r=2=>true;false)
m(b:List Any):Boolean==(for i in b repeat(q:=w(i::Union(List(Any),NNI));q=false=>return false);true)
ungolfed and test
f(x:Union(List(Any),NNI)):Boolean==
x case List(Any)=>
g:List(Any):=x
leaf? g =>return true
for i in g repeat
q:=f(i)
q=false => return false
return true
r:NNI:=x
r=2=>true
false
h(b:List Any):Boolean==
for i in b repeat
q:=f(i::Union(List(Any),NNI))
q=false=> return false
true
(5) -> [[i, m(i)] for i in [ [2],[2,2],[[2],[2,2],2],[],[[],[]] ] ]
(5)
[[[2],true],[[2,2],true],[[[2],[2,2],2],true],[[],true],[[[],[]],true]]
Type: List List Any
(6) -> [[i, m(i)] for i in [ [1],[22],[2,2,2,1], [[1,2],2] ] ]
(6) [[[1],false],[[22],false],[[2,2,2,1],false],[[[1,2],2],false]]
Type: List List Any
Can we take in a string representing the array? – Post Rock Garf Hunter – 2017-05-13T07:42:40.043
Will there be objects other than numbers and other arrays in the arrays – Post Rock Garf Hunter – 2017-05-13T07:43:26.997
There will only be arrays and numbers, and a string representing the array is fine. – ATaco – 2017-05-13T07:44:11.983
Is it okay if we output
0
for truthy testcases, and some positive integer for falsey ones? – user41805 – 2017-05-13T07:46:04.923Can we assume input numbers are positive? – Pavel – 2017-05-13T07:46:50.003
Input numbers will not be non-negative, and any unique output pair is acceptable... – ATaco – 2017-05-13T07:47:21.633
@ATaco Does "unique output pair" mean that "a positive integer for falsey" is not allowed? – Leaky Nun – 2017-05-13T07:56:44.833
I'll allow it, as it's still clearly distinguishable from a truthy result. – ATaco – 2017-05-13T07:57:49.740
@ATaco so what exactly do you allow, and why would a cat program be invalid? – Leaky Nun – 2017-05-13T08:04:13.580
Is it OK to return true` in one case and raise an error in the other? I assume no, but I can shave a byte off if the answer's yes. – ymbirtt – 2017-05-13T08:12:37.597
Atleast one output should be uniquely consistent. And yes, error is fine. – ATaco – 2017-05-13T08:17:35.137
You should clarify exactly what outputs are expected.
– James – 2017-05-13T08:29:17.700Default IO
would imply Truthy-falsy, but the comments say that at least one output should be consistent. https://codegolf.meta.stackexchange.com/q/12305/31716Alright, I'm going to be specific in the challenge, as this comment section is getting too much. – ATaco – 2017-05-13T08:30:35.207
2What kind of numbers? Compex int, compex float, float int, int , not negative? – RosLuP – 2017-05-14T13:53:20.840
What about:" Take an array void or contain integers or contain arrays of integers or array voids, output if it only contains 2s." – RosLuP – 2017-05-14T14:08:31.557
1FTR and in the name of proper mathematical thinking: the array
[[2]]
does not contain a two. – ceased to turn counterclockwis – 2017-05-15T11:08:02.237Can the array contain floating point numbers like
2.2
? – user41805 – 2017-05-15T14:13:19.200