add number->string, string->symbol, symbol->string.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-11 22:36:38 +02:00
parent 5d2259e55e
commit 8c2d53eb32
2 changed files with 35 additions and 0 deletions

23
mes.c
View file

@ -724,6 +724,29 @@ list_to_vector (scm *x)
return v;
}
scm*
number_to_string (scm *x)
{
assert (x->type == NUMBER);
char buf[256];
sprintf (buf,"%d", x->value);
return make_string (buf);
}
scm*
string_to_symbol (scm *x)
{
assert (x->type == STRING);
return make_symbol (x->name);
}
scm*
symbol_to_string (scm *x)
{
assert (x->type == SYMBOL);
return make_string (x->name);
}
scm*
vector_to_list (scm *v)
{

View file

@ -268,4 +268,16 @@
(display (procedure? procedure?))
(newline)
(define *gensym* 0)
(define (gensym)
(set! *gensym* (+ *gensym* 1))
(string->symbol (string-append "g" (number->string *gensym*))))
(display (gensym))
(newline)
(display (gensym))
(newline)
(display (gensym))
(newline)
'()