<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/dcbb97e00ea9ea5a3640e48d394074e9"
  from="Ketanu &lt;ketanu@w...&gt;"
  author="Ketanu"
  date="2002-07-03T08:43:22"
  subject="[Caml-list] Re: generic programming"
  prev="2002/07/086229a0f9b30e86a6556869bfe538ce"
  next="2002/07/0f2535d349e6014a883b1f763837db62"
  prev-in-thread="2002/07/e2cc2ea7d256e2884b0218dbe99e4f49"
  next-in-thread="2002/07/81f12c5cad32eba3f02fcc732a0b0eb6"
  prev-thread="2002/07/562bfd7c9196fc3abcb454d8d4965868"
  next-thread="2002/07/b063648a2dd6d86053cf686570b2117e"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] generic programming">
<msg 
  url="2002/07/729263137a5c609a8795ff7b62ccf4d0"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-03T02:46:19"
  subject="[Caml-list] generic programming">
<msg 
  url="2002/07/086229a0f9b30e86a6556869bfe538ce"
  from="Johan Baltié &lt;johan.baltie@w...&gt;"
  author="Johan Baltié"
  date="2002-07-03T08:43:01"
  subject="Re: [Caml-list] generic programming">
<msg 
  url="2002/07/e2cc2ea7d256e2884b0218dbe99e4f49"
  from="Anton Moscal &lt;msk@m...&gt;"
  author="Anton Moscal"
  date="2002-07-05T13:28:26"
  subject="Re: [Caml-list] generic programming">
</msg>
</msg>
<msg 
  url="2002/07/dcbb97e00ea9ea5a3640e48d394074e9"
  from="Ketanu &lt;ketanu@w...&gt;"
  author="Ketanu"
  date="2002-07-03T08:43:22"
  subject="[Caml-list] Re: generic programming">
<msg 
  url="2002/07/81f12c5cad32eba3f02fcc732a0b0eb6"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-03T17:43:58"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/0314e671c829ee05f5aa5680605ecbd1"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-03T20:04:53"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/46e8a07b4366726933f941e9b77e5607"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-03T20:28:21"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/b0cf4d7882617fd27e03771a31589b70"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-04T15:33:31"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/b4d857a65ae262207463c99e98abb5f7"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-07T20:35:55"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/2702b480e76a128d5e149a4d57a81363"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-08T01:00:11"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/29380c5033d9738e56987cfd04cf7446"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-08T07:23:04"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/10/9771c361af322c3ddf2c05c7693bd197"
  from="Eray Ozkural &lt;erayo@c...&gt;"
  author="Eray Ozkural"
  date="2002-10-15T10:29:08"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/bc290463a2fb18079bf6f399c5a50e6f"
  from="Peter Wood &lt;peter.wood@w...&gt;"
  author="Peter Wood"
  date="2002-07-03T21:53:52"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/54c375615f0a29b27858964a3ea565a1"
  from="james woodyatt &lt;jhw@w...&gt;"
  author="james woodyatt"
  date="2002-07-04T02:02:06"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
<msg 
  url="2002/07/f9169f3ec2d8758bc125264b2df6077c"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-04T15:18:38"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/9ef27ddc21bed28306035ffd3faf0846"
  from="Francois Pottier &lt;francois.pottier@i...&gt;"
  author="Francois Pottier"
  date="2002-07-05T08:42:51"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/fa6f4b49227ef840303e76915d7f82e0"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-05T09:25:54"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/dc781b0623ef875df91c3aafad01e44c"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-05T10:15:23"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/d32dd70947be26ad7baf537ea0fb45f5"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-05T13:54:38"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/aad5a743288a064f4f5588efca0b71f5"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-05T18:18:33"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/6678e85245a3edc1fb95174cb4e3330c"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-05T20:31:27"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
<msg 
  url="2002/07/7d4406847b9935e88eb5bb1f37218e5b"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-05T19:34:05"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
<msg 
  url="2002/07/3259c1827be396d71d70b2c7e2861447"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-05T19:31:26"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/00fb705ed9a16fca4d7ec6fcdd19a976"
  from="Francois Pottier &lt;francois.pottier@i...&gt;"
  author="Francois Pottier"
  date="2002-07-05T08:33:25"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/e5a3d181643111354651fc4afd3d96ab"
  from="Dave Berry &lt;daveb@t...&gt;"
  author="Dave Berry"
  date="2002-07-05T23:02:14"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/08/d395639496023bb4daa54d843df08749"
  from="Diego Olivier Fernandez Pons &lt;Diego-Olivier.FERNANDEZ-PONS@c...&gt;"
  author="Diego Olivier Fernandez Pons"
  date="2002-08-02T14:52:44"
  subject="[Caml-list] Streams">
<msg 
  url="2002/08/929519264a1aa2fef08921548f609164"
  from="Alain Frisch &lt;frisch@c...&gt;"
  author="Alain Frisch"
  date="2002-08-02T15:29:07"
  subject="Re: [Caml-list] Streams">
<msg 
  url="2002/08/3ba1a139a7e1050e9b2233e0cc9eb5c2"
  from="Diego Olivier Fernandez Pons &lt;Diego-Olivier.FERNANDEZ-PONS@c...&gt;"
  author="Diego Olivier Fernandez Pons"
  date="2002-08-03T14:22:03"
  subject="Re: [Caml-list] Streams">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/27f2e9a6fef12ae5f3dfeb79ca878644"
  from="Francois Pottier &lt;francois.pottier@i...&gt;"
  author="Francois Pottier"
  date="2002-07-08T09:54:55"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/f49c4126b9e8f96224a3185f0b93557f"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-08T15:49:08"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/0f2535d349e6014a883b1f763837db62"
  from="Jun P.FURUSE &lt;Jun.Furuse@i...&gt;"
  author="Jun P.FURUSE"
  date="2002-07-03T09:10:27"
  subject="Re: [Caml-list] generic programming">
</msg>
</msg>
</thread>

<contents>
Oleg &lt;oleg_inconnu@myrealbox.com&gt; writes:

&gt; Hi
&gt;
&gt; Is generic programming possible with O'Caml? Suppose I want to find the
&gt; Pearson correlation between two sets of real numbers represented as sets,
&gt; arrays, big_arrays, maps, stacks, queues or lists. Is it possible to have
&gt; one piece of code that handles all of these containers, a generic function
&gt; of some sort? (Iteration is all that is necessary in the Pearson
&gt; correlation example)

Sure it is possible ! You should embed all these containers into either
objects or modules whith homogenous interface suitable for your algorithm,
and then code thge appropriate functor or object which will provide the
algorithm itself.

You may also build streams on the top of your structures and implement
algorithm for strams (if this is suitable with the kind of iteration you
need).

You may also write a function pearson_correlation with the four arguments
set1 set2 iter1 iter2, with types

set1:'a
set2:'b
iter1:'a -&gt; int -&gt; float
iter2:'b -&gt; int -&gt; float

where the iter1,2 functions must provide iteration over the containers
set1,2 (thus, the types for iter1,2 mas need to be adapted to your
iteration). 

Hope it helps !
-- 
Ketanu &lt;katanu@wanadoo.fr&gt; - RSA PGP Key ID: 0x20D90C12

-------------------
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

</contents>

</message>

