[Haskell-cafe] practice problems?
Brian Hulley
brianh at metamilk.com
Sun Sep 3 08:22:09 EDT 2006
Tamas K Papp wrote:
> On Sun, Sep 03, 2006 at 12:47:45PM +0400, Bulat Ziganshin wrote:
>> i also suggest you to start write some library. there is enough
>> useful libs that are still bnot implemented because lack of time (and
>> insterest in such simple code) on side of more experienced
>> programmers. i once proposed you to write strings library, another
>> interesting and useful thing will be gzip/bzip2-lib bindings
>
> Bulat,
>
> I would be happy to write a strings library, I just don't know that it
> is supposed to do... (I have no CS education, only math/economics).
> If you show me the specifications or documentation in another
> language, I would write one as practice.
What about a library for interval arithmetic [1]?
I'd imagine it could start something like:
data Interval a = Interval !a !a deriving (Eq, Show)
instance Num a => Num (Interval a) where
Interval llow lhigh + Interval rlow rhigh = Interval (min llow rlow)
(max lhigh rhigh)
The Interval type would probably need to explicitly represent several kinds
of intervals eg (-infinity, x] etc and there are some tricky issues about
what to do with the operations whose result sometimes needs to be
represented by more than one interval to be useful such as division by an
interval containing zero eg you might want to use a list of intervals to
deal with these cases:
instance Num a => [Interval a] where
...
ie
[Interval 5 5] / [Interval -1 1] = [FromNegInfinityTo -5,
ToPosInfinityFrom 5]
though using a list may make things too slow (ideally it would be nice to
have interval arithmetic that's as fast as normal floating point
arithmetic - is this possible?) Alternatively, these cases could just be
undefined though that might limit the usefulness of the lib.
Another extremely useful thing would be a symbolic math library with a BSD
(or LGPL) license...
And yet another extremely useful thing would be a good library for numerical
computations (there is GSLHaskell but that's licensed under GPL so there
still seems to be a gap for something similar using LGPL or BSD).
In general if you look at
http://www.haskell.org/haskellwiki/Libraries_and_tools/Mathematics there
appear to be many extremely useful libs already written, but unfortunately a
lot of them are not BSD compatible so I think there is a huge gap for math
related libs that people can use for commercial projects.
Anyway just an idea :-),
Brian.
[1] http://en.wikipedia.org/wiki/Interval_arithmetic
--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.
http://www.metamilk.com
More information about the Haskell-Cafe
mailing list