-, , List typedef struct conscell*. , , .
cons , . :
typedef conscell
{
unsigned char *data;
struct conscell* next;
} conscell;
, , char, unsigned char , , lambdas .., unsigned char* void* , .
, , , cons- cons-, , ,
if (token[0] == '(')
{
strcpy(token, getToken());
node->first = nextNode(node->first);
node->rest = nextNode(node->rest);
}
cons- "" ""... , . node "" ( cons-cell, , ), node node .
createList(), , (.. node = NULL, , ' , node). free() node, NULL.
, printList() , , ... node . , . :
void printList(List node)
{
List current = node;
while (current != NULL)
{
if (node->data != NULL)
{
printf("%s", node->data);
}
current = current->next;
}
}
, , 1) cons , , , node. cons'ed , node. 2) , Scheme cons, , " ", , (.. ), . , - (cons 'd (cons 'c (cons 'b (cons 'a '())))), (d c b a). , , , ( , RPN).