Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Discarding elements from a list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: oliver@f...
Subject: Re: [Caml-list] Discarding elements from a list
On Sun, Jan 26, 2003 at 08:01:16PM +0100, Oliver Bandel wrote:
> 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 "->" 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

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
       []     -> []
     | hd::tl -> 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....

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: