Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Martin Jourdan <jourdan@minos>
To: caml-list@margaux
Subject: [foissott@poly.polytechnique.fr: CAML (X90)]
Date: Tue, 26 Jan 93 10:32:02 +0100	[thread overview]
Message-ID: <9301260932.AA18765@cardhu.inria.fr> (raw)

L'un des gourous Caml pourrait-il e'clairer ma lanterne et celle de
mon e'le`ve au sujet des focntions a` deux arguments de'finies par
pattern matching (cf. message ci-dessous)?

D'autre part, est-ce que les mots-cle's "fun" et "function" sont
re'ellement strictement e'quivalents?  Il me semble qu'hier je suis
tombe' sur un cas de non-e'quivalence mais je ne me rappelle plus
lequel.

Merci d'avance.

					Martin

P.S.: tout c,a concerne la version 2.6.1.


    Date: Tue, 26 Jan 93 03:00:57 +0100
    From: foissott@poly.polytechnique.fr (foissotte marc)
    To: jourdan@poly.polytechnique.fr
    Subject: CAML (X90)


	    Cher Monsieur Jourdan,
    Voici une petite session sous caml. La deuxieme definition de la
    fonction insere est correcte: visiblement on peut definir une fonction
    a plusieurs arguments (avec fun) en utilisant le pattern-matching,
    mais seul le premier argument doit comporter un pattern! Ou bien c'est
    assez limitatif, ou bien il y a une restriction de syntaxe qui
    m'echappe (ce que j'espere...), et je ne parviens pas a trouver la
    solution dans les manuels. Pourriez vous m'eclairer?
	    Merci d'avance,
	      Marc Foissotte (foissott@poly)

    #
    #(* insere x [1;2;3] = [[x;1;2;3];[1;x;2;3];[1;2;x;3];[1;2;3;x]] *)
    #
    #let rec insere = fun
    #  x [] -> [[x]]
    # |x (h::t) -> (x::h::t)::(map ajoute (insere x t))
    #    where ajoute l = (h::l) ;;
    Warning: 2 partial matches in this phrase
    Warning: 1 unused match case in this phrase
    Value insere = <fun> : ('a -> 'a list -> 'a list list)

    #insere 7 [1;2;3] ;;

    Pattern matching Failed

    #
    #(* insere [1;2;3] x = [[x;1;2;3];[1;x;2;3];[1;2;x;3];[1;2;3;x]] *)
    #
    #let rec insere = fun
    #  [] x -> [[x]]
    # |(h::t) x -> (x::h::t)::(map ajoute (insere t x))
    #    where ajoute l = (h::l) ;;
    Value insere = <fun> : ('a list -> 'a -> 'a list list)

    #insere [1;2;3] 7 ;;
    [[7; 1; 2; 3]; [1; 7; 2; 3]; [1; 2; 7; 3]; [1; 2; 3; 7]] : num list list




                 reply	other threads:[~1993-01-27 10:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=9301260932.AA18765@cardhu.inria.fr \
    --to=jourdan@minos \
    --cc=caml-list@margaux \
    /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