add number->string, string->symbol, symbol->string.
This commit is contained in:
parent
5d2259e55e
commit
8c2d53eb32
23
mes.c
23
mes.c
|
@ -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)
|
||||
{
|
||||
|
|
12
test.mes
12
test.mes
|
@ -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)
|
||||
|
||||
'()
|
||||
|
|
Loading…
Reference in a new issue