Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: marche@lri.fr
To: caml-list@margaux
Subject: empty list
Date: Mon, 24 May 93 10:08:51 +0200	[thread overview]
Message-ID: <9305240808.AA02830@sun8.lri.fr> (raw)


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






             reply	other threads:[~1993-05-24 13:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-05-24  8:08 marche [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-05-18 17:59 Stefan Krischer

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=9305240808.AA02830@sun8.lri.fr \
    --to=marche@lri.fr \
    --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