Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: oliver@first.in-berlin.de (Oliver Bandel)
To: caml-list@inria.fr
Subject: Re: [Caml-list] Discarding elements from a list
Date: Sun, 26 Jan 2003 20:28:39 +0100	[thread overview]
Message-ID: <20030126192839.GA486@first.in-berlin.de> (raw)
In-Reply-To: <20030126190116.GA360@first.in-berlin.de>

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

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


  reply	other threads:[~2003-01-26 19:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-26 19:01 Oliver Bandel
2003-01-26 19:28 ` Oliver Bandel [this message]
2003-01-26 23:27   ` malc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030126192839.GA486@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox