DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T l

⟦d062c5bfd⟧ TextFile

    Length: 780 (0x30c)
    Types: TextFile
    Names: »list.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Kriegspiel/list.c« 

TextFile

/* list.c */

#include "constants.h"
#include <curses.h>

struct IN
{
	int i;
	struct IN *n;
};
typedef struct IN *LIST;

LIST
linsert (list, number)
	LIST list;
	int number;
{
	LIST cell;

	char *malloc ();
	cell = (LIST) malloc (sizeof (struct IN));
	cell->i = number;
	cell->n = list;
	return cell;
}

LIST
lmember (number, list)
	int number;
	LIST list;
{
	while (list != NIL) {
		if (list->i == number)
			return list;
		list = list->n;
	}
	return FALSE;
}

llength (list)
	LIST list;
{
	int i;

	i = 0;
	while (list != NIL) {
		i++;
		list = list->n;
	}
	return i;
}

lfront (sublist, list)
	LIST sublist, list; /* both must be non-NIL */
	/* Allows easy deletion, when combined with lmember.  Violent. */
{
	int n;

	n = list->i;
	list->i  = sublist->i;
	sublist->i = n;
}