/* examples - how to use liblmin */

#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdarg.h>

#include "../liblmin.h"
#include "../leakfinder.h"

static lmin_cellidx hello( lmin_cellidx f, lmin_cellidx c, lmin_cellidx e )
    {
    lmin_cellidx val1;
    val1 = lmin_first( c );
    printf( "Hello, %s!\n", lmin_str_get( val1 ) );
    return lmin_t;
    }

int main( int argc, char** argv )
    {
    lmin_cellidx list;

    /* Call lmin_init() when your program starts. */
    lmin_init();

    /* Add a C routine as a LISP function. */
    lmin_prim_make( "hello", hello, "(\"string\" where)", false );

    /* Call a LISP function from C. */
    lmin_eval( lmin_parse( "(hello \"world\")" ), lmin_nil );

    /* Another way to call LISP from C. */
    list = lmin_parse( "(list 's' 'd' 'r' 'a' 'w' 'k' 'c' 'a' 'b')" );
    lmin_write_line( lmin_call( "reverse", list, lmin_nil ), stdout );

    /* Call lmin_term() when your program is done. */
    lmin_term();
    exit( 0 );
    }
