Re: [pure-lang-users] case
Status: Beta
Brought to you by:
agraef
From: Eddie R. <er...@bm...> - 2008-08-28 12:38:38
|
On Thu, 2008-08-28 at 02:37 +0200, Albert Graef wrote: > BTW, using 'set' for the setter is a bad idea, that's already used in > set.pure. Actually the thingy I sent was bad. (m, setter) should have been (m, set) like in the following. Since set is local to matrix and we have lexical scoping, I see no problem. I can see wherethe typo in the previous would lead you to believe set was global. matrix ys@(x:xs) = Matrix type (do (\i -> do (\j -> set m i j (type ((ys!i)!j))) (0..c-1)) (0..r-1) $$ m) when r = #ys; c = #x; type = if foldl1 (*) (map (\x -> all intp x) ys) then int else double; (m, set) = if type === int then gsl_matrix_int_alloc r c, gsl_matrix_int_set else gsl_matrix_alloc r c, gsl_matrix_set; end; > symbolic constants for the different types. Or you could just pass a > "witness" of the type and then match against _::int etc.) I'm thinking about this. The case type of would make for easier reading when I add the complex matrix type in. Hope you got some good sleep. e.r. |