LISP generalized lists in C
- From: Jean-Guillaume Pyraksos <wissme@xxxxxxxxxxx>
- Date: Tue, 11 Apr 2006 16:00:32 +0200
I want to work with "generalized lists" as in Lisp, say :
((23 () . 2) () ((10))) ; only pointers and integers
So the basic element is a node, a struct with two fields car and cdr.
Each of these fields can contain either a pointer (NULL or a pointer to
another node), or an int.
I want to define the functions cons, car and cdr of Lisp.
I tried this but gcc rejects it :
#include <stdio.h>
#include <stdlib.h>
typedef struct {
object car;
object cdr;
} node;
typedef struct {
int tag; // 0==int, 1==node*
union {
int value;
node *ptr;
} val;
} object;
node* cons(object a, object b) { ...}
Can you help ? Thanks...
JG
.
- Follow-Ups:
- Re: LISP generalized lists in C
- From: Duncan Muirhead
- Re: LISP generalized lists in C
- From: tmp123
- Re: LISP generalized lists in C
- From: Eric Sosman
- Re: LISP generalized lists in C
- Prev by Date: Re: pgm without std library functions
- Next by Date: Re: FAQ 1.12--auto keyword
- Previous by thread: Re: Initializing static structs
- Next by thread: Re: LISP generalized lists in C
- Index(es):
Relevant Pages
|