<?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/12/ec6b4886b2c39dc65c0dac1c458cf870"
  from="Pal-Kristian Engstad &lt;engstad@n...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-12-05T21:14:06"
  subject="Re: [Caml-list] Why is (@) written in O&apos;Caml?"
  prev="2002/12/87e12bef39b1bf9fc066aa51f3deb525"
  next="2002/12/df161cd8b28e51dc38f18457ea08df92"
  prev-in-thread="2002/12/be49727f9a0b54ea11c73a1fa9e19c68"
  next-in-thread="2002/12/df161cd8b28e51dc38f18457ea08df92"
  prev-thread="2002/12/e39e48c52e7ed2ec723bb0d96798451f"
  next-thread="2002/12/5601889e766f585d4843a475bbbf5315"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Why is (@) written in O&apos;Caml?">
<msg 
  url="2002/12/be49727f9a0b54ea11c73a1fa9e19c68"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-12-05T20:47:33"
  subject="[Caml-list] Why is (@) written in O&apos;Caml?">
<msg 
  url="2002/12/ec6b4886b2c39dc65c0dac1c458cf870"
  from="Pal-Kristian Engstad &lt;engstad@n...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-12-05T21:14:06"
  subject="Re: [Caml-list] Why is (@) written in O&apos;Caml?">
<msg 
  url="2002/12/df161cd8b28e51dc38f18457ea08df92"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-12-05T21:25:02"
  subject="Re: [Caml-list] Why is (@) written in O&apos;Caml?">
<msg 
  url="2002/12/c4388ecb31fe654b6fb22eeec02a35dc"
  from="Pal-Kristian Engstad &lt;engstad@n...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-12-05T21:53:40"
  subject="Re: [Caml-list] Why is (@) written in O&apos;Caml?">
<msg 
  url="2002/12/fc6d1c354a67a69a3e554def663ab92b"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-12-05T23:28:08"
  subject="Re: [Caml-list] Why is (@) written in O&apos;Caml?">
<msg 
  url="2002/12/d1a700fd99422f1af2c8e0eab4d042a5"
  from="Pal-Kristian Engstad &lt;engstad@n...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-12-05T23:51:02"
  subject="Re: [Caml-list] Why is (@) written in O&apos;Caml?">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
On Thursday 05 December 2002 12:47 pm, Oleg wrote:
&gt; let rec (@) l1 l2 =
&gt;   match l1 with
&gt;     [] -&gt; l2
&gt;
&gt;   | hd :: tl -&gt; hd :: (tl @ l2)
&gt;
&gt; The O'Caml implementation of (@) is recursive and not tail-recursive. All
&gt; one really has to do during "append" is copy l1 and set the last element's
&gt; CDR to l2. I can see why this can not be done in O'Caml itself, but since
&gt; (@) is such a common operation, I'm wondering why it was decided to
&gt; implement it inefficently in O'Caml itself?

You say you want to copy l1 and then set the last element of tail to l2? But, 
that is _exactly_ what the function above does! 

let copy l1 = 
  match l1 with
    [] -&gt; []
  | hd :: tl -&gt; hd :: copy tl

Right? So, the only change is the extra argument l2, that is being appended 
onto the list when l1 is empty. 

PKE.
-- 
  _       
  \`.       Pål-Kristian Engstad, Senior Software Engineer,
   \ `|     Naughty Dog, Inc., 1315 3rd Street Promenade, 
  __\ |`.   Santa Monica, CA 90046, USA. (310) 752-1000 x799. 
    /  /o   mailto:engstad@naughtydog.com http://www.naughtydog.com
   /  '~    mailto:mrengstad@yahoo.com    http://www.engstad.com
  / ,'      Hang-gliding Rulez!
  ~'

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

