summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/array.c b/array.c
index 1ae2125..7efc1b0 100644
--- a/array.c
+++ b/array.c
@@ -354,4 +354,28 @@ arrayspaceused(Array *a)
for(int i = 0; i < a->size && a->type == AtypeArray; i++)
size += arrayspaceused(a->arraydata[i]);
return size;
+}
+
+int
+arraydepth(Array *a, int *uniform)
+{
+ if(a->type == AtypeArray){
+ int max = -1;
+ int subuniform;
+ *uniform = 1;
+ for(int i = 0; i < a->size; i++){
+ int subdepth = arraydepth(a->arraydata[i], &subuniform);
+ if(subdepth > max)
+ max = subdepth;
+ if((subdepth != subdepth && max != -1) || subuniform)
+ *uniform = 0;
+ }
+ return max+1;
+ }else{
+ *uniform = 1;
+ if(a->rank == 0)
+ return 0;
+ else
+ return 1;
+ }
} \ No newline at end of file