[Haskell-cafe] Specify array or list size?
Abraham Egnor
abe.egnor at gmail.com
Sat May 7 15:12:19 EDT 2005
On 5/7/05, Jacob Nelson <jake at jfet.net> wrote:
>
> GCC knows how big an array is:
>
> jake$ cat > arrsizetest.c
> #include <stdio.h>
>
> int main()
> {
> int a[50];
> printf("sizeof a == %d\n",sizeof(a));
> return 0;
> }
> jake$ gcc arrsizetest.c
> jake$ ./a.out
> sizeof a == 200
So does ghc:
import Data.Array
main =
let a = listArray (0, 49) $ replicate 50 0
in putStrLn $ "array size == " ++ show (rangeSize $ bounds a)
[abe at catspaw:~/src/test/haskell] $ runghc arrsize.hs
array size == 50
That doesn't mean the size is part of the *type*.
Abe
More information about the Haskell-Cafe
mailing list