def _ca(items, s):
 if atomp(items):
  return items
 if (len(s) == 0):
  return items[0]
 lst = ([0] * s[0])
 stride = ((len(items) // s[0]) if s[0] else 0)
 for i in range(s[0]):
  start = (i * stride)
  lst[i] = _ca(items[start:(start + stride)], s[1:])
 return lst

def _ca ( items , s ) : if atomp ( items ) : return items if ( len ( s ) == 0 ) : return items [ 0 ] lst = ( [ 0 ] * s [ 0 ] ) stride = ( ( len ( items ) // s [ 0 ] ) if s [ 0 ] else 0 ) for i in range ( s [ 0 ] ) : start = ( i * stride ) lst [ i ] = _ca ( items [ start : ( start + stride ) ] , s [ 1 : ] ) return lst
convert flat item list to the nested list representation of a multidimensional c array with shape s .