Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* empty list
@ 1993-05-18 17:59 Stefan Krischer
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Krischer @ 1993-05-18 17:59 UTC (permalink / raw)
  To: caml-list

Hello mailing-list,

Does anyone know how to test in a C program if a CAMLlight list is empty?


Stefan Krischer

--------------------------------------------------------------------------------
Currently at Carnegie-Mellon-University (until june 11th)
E-mail:         krischer@cs.cmu.edu, krischer@loria.fr
Research group EURECA (CRIN/CNRS & INRIA-Lorraine)
--------------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 2+ messages in thread

* empty list
@ 1993-05-24  8:08 marche
  0 siblings, 0 replies; 2+ messages in thread
From: marche @ 1993-05-24  8:08 UTC (permalink / raw)
  To: caml-list


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 <mlvalues.h>

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 <alloc.h>
#include <memory.h>


/*=============

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;
}






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1993-05-24 13:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-05-18 17:59 empty list Stefan Krischer
1993-05-24  8:08 marche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox