1 /* -*-comment-start: "//";comment-end:""-*-
2 * Mes --- Maxwell Equations of Software
3 * Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
5 * This file is part of Mes.
7 * Mes is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
12 * Mes is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Mes. If not, see <http://www.gnu.org/licenses/>.
22 number_to_string (SCM x)
24 assert (TYPE (x) == NUMBER);
26 SCM p = n < 0 ? cons (MAKE_CHAR ('-'), cell_nil) : cell_nil;
28 p = cons (MAKE_CHAR (n % 10 + '0'), p);
31 return MAKE_STRING (p);
35 string_to_symbol (SCM x)
37 assert (TYPE (x) == STRING);
38 return STRING (x) == cell_nil ? cell_nil : make_symbol (STRING (x));
42 symbol_to_string (SCM x)
44 assert (TYPE (x) == SYMBOL);
45 return MAKE_STRING (STRING (x));
49 keyword_to_symbol (SCM x)
51 assert (TYPE (x) == KEYWORD);
52 return make_symbol (STRING (x));
56 symbol_to_keyword (SCM x)
58 assert (TYPE (x) == SYMBOL);
59 g_cells[tmp_num].value = KEYWORD;
60 return make_cell (tmp_num, STRING (x), 0);