[Haskell-cafe] dimension of arrays

Fred Nicolier f.nicolier at iut-troyes.univ-reims.fr
Mon Mar 29 16:34:45 EST 2004


Josef Svenningsson wrote:

>In a sense Haskell arrays are always one dimensional. But as you noted
>tuples are used to achieve higher dimensionality. As far as I know there
>is no way of asking for the dimension of an array. You could write your
>own class for that though. Here's a suggestion:
>
>\begin{code}
>dims :: (Ix a, HasDimension a) => Array a b -> Int
>dims arr = dimension (head (range arr))
>
>  
>
with the following correction, it is ok.

dims arr = dimension (head (range $ bounds arr))

thanks at lot
Fred





-- 
-------------------------------------------------------
Dr. Frederic Nicolier
Maitre de conferences, laboratoire LAM - URCA
Animateur du projet ANITA : http://f.nicolier.free.fr/recherches/
Dept. GE&II, IUT de Troyes
9 rue de Quebec
10026 Troyes Cedex
Tel: 03 25 42 71 01
Std: 03 25 42 46 46
Fax: 03 25 42 46 43
email: f.nicolier at iut-troyes.univ-reims.fr              
---------------------------------------------------------



More information about the Haskell-Cafe mailing list