hashmap withdrawal and poor haskell style
Martin Norbäck
d95mback@dtek.chalmers.se
03 Apr 2002 17:54:05 +0200
--=-OvpYi9qrwmCboojs3N3D
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
ons 2002-04-03 klockan 15.51 skrev Daan Leijen:
> > import Array
> >
> > type Histogram =3D Array Char Int
> >
> > histogram :: String -> Histogram
> > histogram input
> > =3D accumArray (+) 0 (minBound,maxBound) [(c,1) | c <- input]
>=20
> (The "minBound" and "maxBound" functions are overloaded from the
> "Bounded" class and give the minimal and maximal character).
Take care here though, since Char might be unicode, you may be
allocating a BIG array.
ghci:
Ix.rangeSize (minBound :: Char, maxBound)
1114112
hugs:
Ix.rangeSize (minBound :: Char, maxBound)
256
(1114112 is 17*2^16)
Regards,
Martin
--=20
Martin Norb=E4ck d95mback@dtek.chalmers.se =20
Kapplandsgatan 40 +46 (0)708 26 33 60 =20
S-414 78 G=D6TEBORG =20
http://www.dtek.chalmers.se/~d95mback/
SWEDEN OpenPGP ID: 3FA8580B
--=-OvpYi9qrwmCboojs3N3D
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: För information se http://www.gnupg.org/
iD8DBQA8qyWdkXyAGj+oWAsRAjSyAJ9k9zTxE/6mQGcSSd8TrbSnfaIq0QCeJYYk
VIaP9iFxtKsoSYQg+s1edQ0=
=4b9e
-----END PGP SIGNATURE-----
--=-OvpYi9qrwmCboojs3N3D--