<?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/912f07947699893b4b8d26c231b9ebe9"
  from="oliver@f..."
  author="oliver@f..."
  date="2003-01-26T19:35:04"
  subject="Re: [Caml-list] Discarding elements from a list"
  prev="2003/01/15cd7ca215908267fbf01507e08c168c"
  next="2003/01/a68be086506e704ff7bd9066a5b771c8"
  prev-in-thread="2003/01/15cd7ca215908267fbf01507e08c168c"
  next-in-thread="2003/01/a68be086506e704ff7bd9066a5b771c8"
  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>
On Sun, Jan 26, 2003 at 08:01:16PM +0100, Oliver Bandel wrote:
[...]
&gt; 
&gt; a) Converting the list to an array, shorten the array,
&gt;    converting back to a list, using the list in a functional
&gt;    manner.
&gt; 
&gt; b) Using pattern match to throw away the first element, then
&gt;    working in the part after the "-&gt;" with a function, which
&gt;    works on the rest of the list.
&gt; 
&gt; c) using a function, which uses an index, for counting, at which
&gt;    position we are inside of the list


OK, I've found a very simple solution. :)

OK, it is functional programming.....

OK, it is Ocaml...

OK, I use pattern matching....


OK, this is my solution:



let discard_first lis = match lis with
       []     -&gt; []
     | hd::tl -&gt; tl


So, the main way to get a solution to a program in fp
is simply: write a function for the simplest case,
and then use that function...


The last days I often, over and over again found,
that I most of the times think more complicated,
than a solution in FP is!

Maybe this "think complicated" is an imperative illness.  (?!)

And more and more I see, what the difference between FP and IP is:
It's much more easy than an IP-programmer thought that it is.

It's unbelievable, that I every day see more examples of
how easy programming can be, if it is functional.


nearly unbelievable....

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>

