users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading prolog terms


From: Lindsey Spratt
Subject: Re: reading prolog terms
Date: Thu, 21 Nov 2002 10:50:30 -0600

Here are some thoughts:

I assume your 'arg[2]' is filled in by a call to gprolog, and that you are now trying to extract the list assumed to be in arg[2]. The following code gets pointers to the terms in 'arg[2]' into an array 'itemTerms'. Then you can walk over this array getting each 'term' and processing it (e.g. converting an atom to a string).

PlTerm itemsListTerm = arg[2];

if( Blt_List(itemsListTerm )
{
        int itemsListLength = List_Length(itemsListTerm);
        PlTerm * itemTerms = calloc( sizeof(void*), itemsListLength );
        PlTerm term = NULL;

        Rd_Proper_List(itemsListTerm, itemTerms);

        for( ofst = 0; ofst < itemsListLength; ofst++ )
        {
                term = itemTerms[ofst];
                /* do interesting stuff with 'term' here. */
        }
}

Hope this helps,
Lindsey Spratt
http://homepage.mac.com/lspratt






reply via email to

[Prev in Thread] Current Thread [Next in Thread]