Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Pierre Weis <Pierre.Weis@inria.fr>
To: matias@k-bell.com
Cc: caml-list@inria.fr
Subject: Re: [Q] Multiple patterns in O'Caml
Date: Wed, 27 Jan 1999 15:02:49 +0100 (MET)	[thread overview]
Message-ID: <199901271402.PAA15684@pauillac.inria.fr> (raw)
In-Reply-To: <36AE0E34.6BF3A367@k-bell.com> from "=?iso-8859-1?Q?Mat=EDas?= Giovannini" at Jan 26, 99 03:49:28 pm

> (* In O'Caml *)
> let rec drop n l = match (n,l) with
> | 0,l -> l
> | n,[] -> failwith "drop"
> | n,a::x -> drop (pred n) x
> ;;
> 
> but this requires an extraneous tuple construction and its subsequent
> destruction, and kinda seems wasteful to me.
> 
> Thank you in advance, best regards
> Matías.

There is no spurious construction of tuples nor subsequent destuction
when matching an immediate tuple: this is optimised by the compiler of
Objective Caml. This way you can consider writing

match x, y, z with
| 1, 2, 3 -> ...
...

as a syntactic notation for ``parallel matching'', or matching of more
than one value at a time.

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/





      reply	other threads:[~1999-01-27 18:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-26 18:49 Matías Giovannini
1999-01-27 14:02 ` Pierre Weis [this message]

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=199901271402.PAA15684@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=matias@k-bell.com \
    /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