Posts

Petrella Tifernina

Image
Petrella Tifernina comune Localizzazione Stato   Italia Regione Molise Provincia Campobasso Amministrazione Sindaco Alessandro Amoroso (lista civica Il Melograno) dal 26/05/2014 Territorio Coordinate 41°41′N 14°42′E  /  41.683333°N 14.7°E 41.683333; 14.7  ( Petrella Tifernina ) Coordinate: 41°41′N 14°42′E  /  41.683333°N 14.7°E 41.683333; 14.7  ( Petrella Tifernina ) Altitudine 651 m s.l.m. Superficie 26,52 km² Abitanti 1 129 [1] (31-3-2018) Densità 42,57 ab./km² Comuni confinanti Castellino del Biferno, Limosano, Lucito, Matrice, Montagano Altre informazioni Cod. postale 86024 Prefisso 0874 Fuso orario UTC+1 Codice ISTAT 070052 Cod. catastale G512 Targa CB Cl. sismica zona 2 (sismicità media) Nome abitanti petrellesi Patrono san Giorgio Martire Giorno festivo 23 aprile Cartografia Petrella Tifernina Posizione del comune di Petrella Tifernina nella provi...

How do I transpose the first and deepest levels of an arbitrarily nested array?

Image
6 $begingroup$ Is there a straightforward way to convert arr = { {a, b}, {a, b}, {{{a, b}, {a, b}, {a, b}}, {{a, b}, {a, b}, {a, b}}} }; to: {{a, a, {{a, a, a}, {a, a, a}}}, {b, b, {{b, b, b}, {b, b, b}}}} ? I need to swap the first and last dimension. Which should in principle be possible, because, although arr does not have a fixed structure, the 'bottom' is always uniform: Level[arr, {-2}] {{a, b}, {a, b}, {a, b}, {a, b}, {a, b}, {a, b}, {a, b}, {a, b}} Had Transpose / Flatten / MapThread accepted a negative level specification, it would have been easy. That is not the case. One can think about that question as: How do I create arr2 so that arr[[whatever__, y_]] == arr2[[y, whatever__]] ? EDIT: In general Level[arr, {-2}] should be a rectangular array, but rows do not...