<?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="2003/01/15cd7ca215908267fbf01507e08c168c"
  from="oliver@f..."
  author="oliver@f..."
  date="2003-01-26T19:00:08"
  subject="[Caml-list] Discarding elements from a list"
  prev="2003/01/8ee94a5b5e46b261b7599c6003b3a18b"
  next="2003/01/912f07947699893b4b8d26c231b9ebe9"
  next-in-thread="2003/01/912f07947699893b4b8d26c231b9ebe9"
  prev-thread="2003/01/2a90151cd7b925c19cbd206907343e50"
  next-thread="2003/01/874b3b370b0e9f79e2b4b39bef346098"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Discarding elements from a list">
<msg 
  url="2003/01/15cd7ca215908267fbf01507e08c168c"
  from="oliver@f..."
  author="oliver@f..."
  date="2003-01-26T19:00:08"
  subject="[Caml-list] Discarding elements from a list">
<msg 
  url="2003/01/912f07947699893b4b8d26c231b9ebe9"
  from="oliver@f..."
  author="oliver@f..."
  date="2003-01-26T19:35:04"
  subject="Re: [Caml-list] Discarding elements from a list">
<msg 
  url="2003/01/a68be086506e704ff7bd9066a5b771c8"
  from="malc &lt;malc@p...&gt;"
  author="malc"
  date="2003-01-26T23:25:59"
  subject="Re: [Caml-list] Discarding elements from a list">
</msg>
</msg>
</msg>
</thread>

<contents>
Hello,


after Remi has pushed my towards rewriting my
"I do it like I know it, and therefore imperative"
version of a program into a functional version of
this program (thanks, Remi, I have explored a lot
new things since then :)) I sometimes come to
this problem:

I have to use a partial list.

In the reference manual I did not found any
stdlib-function, and so I have two ideas,
of how to perform e.g. a list, which is used
without the head (throwing away first element):

a) Converting the list to an array, shorten the array,
   converting back to a list, using the list in a functional
   manner.

b) Using pattern match to throw away the first element, then
   working in the part after the "-&gt;" with a function, which
   works on the rest of the list.

c) using a function, which uses an index, for counting, at which
   position we are inside of the list


This problem arises, when a list, on which should be worked,
will be created and it must be used a part of it (e.g. all
elements but the last or all elements but the first), like
creating a multiplication of the last and the current element...
(like fibonacci uses addition, I need multiplication here)
and when the first or last is necessary for some calculation,
but should be thrown away for some other calculation.

Because I have no criteria to decide, which solution I should
prefer (and why), I always rethink the problem again,
and the decision-process slows down.

So, why should I use which solution?

(And how to select parts of a list in general, not only
 throwing away the first or last element?)

Any hints?


Ciao,
   oliver
-------------------
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>

