Browse thread
[Caml-list] Easy solution in OCaml?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | malc <malc@p...> |
| Subject: | Re: [Caml-list] Easy solution in OCaml? |
On Fri, 25 Apr 2003, Siegfried Gonzi wrote:
> Hi:
>
> First off: It is not homework. I am 29 and writing my PhD in physics.
> Often I am contemplating whether it would be possible to use OCaml in
> combination with my beloved Bigloo to perform statistical evaluations. I
> am not sure whether there are any out there who /can/ do this
> evaluations with OCaml what you normally would do with Matlab. The
> problem what arises: type system and working against the compiler. In
> Scheme changing a solution from lets say integer-array to double-array
> is easy, but in Clean for example you would have to change all your
> dependencies.
> I often skim over the libraries and came to the conclusion: C, C++,
> OCaml impossible for me to see any elegance; Clean a bit better;
> Bigloo/Scheme: I am not sure here, because everything looks the same
> maybe this is cheating, but I think it looks the most elegant and less
> intimitating from all.
>
>
> Rationale: given a list of 12 month. I would like to calculate the
> quarterly means and skip any nan. Easy? Yes it is but only on paper and
> in Scheme:
>
> e.g: [1,2,4,-1,45,56,45,56,8]
>
> nan=-1.0
>
> result: [(1+2+3)/3, (45+56)/2, (45+56+8)/3]
let nan = -1
let mean a b c = (a + b + c) / 3
let rec qmean = function
a :: b :: c :: rest -> mean a b c :: qmean rest
| [] -> []
| otherwise -> failwith "malformed list"
let _ =
let months = [1; 2; 4; -1; 45; 56; 45; 56; 8] in
let denan = List.map (fun x -> if x = nan then 0 else x) months in
qmean denan
--
mailto:malc@pulsesoft.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners