From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by margaux.inria.fr, Mon, 24 May 93 15:26:38 +0200 Received: from corton.inria.fr by margaux.inria.fr, Mon, 24 May 93 10:10:10 +0200 Received: from lri.lri.fr by corton.inria.fr (5.65c8d/92.02.29) via Fnet-EUnet id AA16718; Mon, 24 May 1993 10:10:44 +0200 (MET) Received: from sun8.lri.fr by lri.lri.fr, Mon, 24 May 1993 10:08:50 +0200 (sender-id: marche@sun8.lri.fr) Received: by sun8.lri.fr, Mon, 24 May 93 10:08:51 +0200 Date: Mon, 24 May 93 10:08:51 +0200 From: marche@lri.fr Message-Id: <9305240808.AA02830@sun8.lri.fr> To: caml-list@margaux Subject: empty list Sender: weis@margaux Hello caml-lighters, For my own program, I have written a small "list" C module, since this may be of a general interest, I send it to the list... ----------------- camllist.h ---------------- /*************************************************************************** Le type list de CAML : interface Projet: NORMCOMP Auteur(s): Claude March\'e Nom du fichier: camllist.h Creation: 27 jan 93 Derniere Modification: 02 fev 93 ***************************************************************************/ #if !defined(CAMLLIST_H) #include typedef value liste; /*============= Constructeurs =============*/ liste liste_vide(void); liste construit_liste(value x,liste l); /*=============== Observateurs ===============*/ #define EST_VIDE(l) (!Tag_val(l)) #define N_EST_PAS_VIDE(l) (Tag_val(l)) #define TETE_DE_LISTE(l) (Field(l,0)) #define QUEUE_DE_LISTE(l) (Field(l,1)) /*======================== Fonctions sur les listes ========================*/ liste concatene_listes(liste l1,liste l2); #define CAMLLIST_H #endif ----------------- camllist.c ---------------- /*************************************************************************** Le type list de CAML : corps Projet: NORMCOMP Auteur(s): Claude Marche' Nom du fichier: camllist.c Creation: 27 jan 93 Derniere Modification: 05 fev 93 ***************************************************************************/ #include "camllist.h" #include #include /*============= Constructeurs =============*/ #define NIL_tag 0 #define CONS_tag 1 liste liste_vide(void) { return Atom(NIL_tag); } liste construit_liste(value x,liste l) { value m; Push_roots(r,2); r[0] = x; r[1] = l; m=alloc(2,CONS_tag); Field(m,0) = r[0]; Field(m,1) = r[1]; Pop_roots(); return m; } /*============ Observateurs ============*/ /*======================== Fonctions sur les listes ========================*/ liste concatene_listes(liste l1,liste l2) { liste result; Push_roots(r,3); r[0] = l1; r[1] = l2; if (N_EST_PAS_VIDE(r[0])) { r[2] = concatene_listes(QUEUE_DE_LISTE(r[0]),r[1]); result = construit_liste(TETE_DE_LISTE(r[0]),r[2]); } else { result = r[1]; } Pop_roots(); return result; }