1 /* -*-comment-start: "//";comment-end:""-*-
2 * Mes --- Maxwell Equations of Software
3 * Copyright © 2016,2017,2018 Jan (janneke) 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/>.
25 SCM x = make_cell__ (TVECTOR, k, v);
26 for (int i=0; i<k; i++)
27 g_cells[v+i] = g_cells[vector_entry (cell_unspecified)];
34 return make_vector__ (VALUE (n));
40 assert (TYPE (x) == TVECTOR);
41 return MAKE_NUMBER (LENGTH (x));
45 vector_ref (SCM x, SCM i)
47 assert (TYPE (x) == TVECTOR);
48 assert (VALUE (i) < LENGTH (x));
49 SCM e = VECTOR (x) + VALUE (i);
52 if (TYPE (e) == TCHAR)
53 e = MAKE_CHAR (VALUE (e));
54 if (TYPE (e) == TNUMBER)
55 e = MAKE_NUMBER (VALUE (e));
62 if (TYPE (x) == TPAIR || TYPE (x) == TSPECIAL || TYPE (x) == TSTRING || TYPE (x) == TSYMBOL || TYPE (x) == TVECTOR)
68 vector_set_x (SCM x, SCM i, SCM e)
70 assert (TYPE (x) == TVECTOR);
71 assert (VALUE (i) < LENGTH (x));
72 g_cells[VECTOR (x)+VALUE (i)] = g_cells[vector_entry (e)];
73 return cell_unspecified;
77 list_to_vector (SCM x)
80 SCM v = make_vector__ (length__ (x));
84 g_cells[p++] = g_cells[vector_entry (car (x))];
91 vector_to_list (SCM v)
94 for (int i = LENGTH (v); i; i--)
96 SCM e = VECTOR (v)+i-1;