English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
RE: [Caml-list] variant with tuple arg in pattern match?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-04-17 (17:33)
From: John Prevost <jmp@a...>
Subject: Re: [Caml-list] variant with tuple arg in pattern match?
>>>>> "db" == Dave Berry <Dave@kal.com> writes:

    db> As for syntax versus semantics, I nearly wrote "semantic
    db> hack", until I realised that it only works if the syntax also
    db> supports it.

Actually, it works regardless.  It's just that a convenient syntax
makes it nicer.  For example:

(define (map f)
  (let ((map' l)
        (cond ((cons? l) (cons (f (car l)) (map' (cdr l))))
              (t         l))

((map (lamba (x) (+ x 2))) '(1 2 3 4 5))

This is a curried function in Scheme: it's not as nice as in a
language with a simpler (juxtaposition) application syntax, but it's
the same operation.  It's just that ML makes using curried functions

The fact that this is more possible in Scheme, by the way, is one of
the things that makes Scheme superior to Lisp.  The fact that function
values and normal values are considered to be different in Lisp just
complicates things.

To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr