
12 Nov
2012
12 Nov
'12
8:32 p.m.
On 11/12/12 07:05, Aleksey Khudyakov wrote:
I have a lot of one-off code where I've defined these myself. Is it possible to e.g. define vectors in R^2 and R^3, and write the p-norm functions only once?
Yes. it's possible.
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} import Data.Vector.Fixed as V import Data.Vector.Fixed.Internal -- ^^^ Needed for Fun /will be reexported from Data.Vector.Fixed import Data.Vector.Fixed.Unboxed
First we need to define data types and instances. It's possible to use vectors from library
...
Thanks, this looks like exactly what I need. I'll try to replace my R^2 and R^3 implementations the next time I do my homework before the last minute.