caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [foissott@poly.polytechnique.fr: CAML (X90)]
@ 1993-01-26  9:32 Martin Jourdan
  0 siblings, 0 replies; only message in thread
From: Martin Jourdan @ 1993-01-26  9:32 UTC (permalink / raw)
  To: caml-list

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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1993-01-27 10:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-01-26  9:32 [foissott@poly.polytechnique.fr: CAML (X90)] Martin Jourdan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).