1 /* -*-comment-start: "//";comment-end:""-*-
2 * Mes --- Maxwell Equations of Software
3 * Copyright © 2016,2017 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/>.
25 VALUE (tmp_num) = TVECTOR;
27 SCM x = make_cell_ (tmp_num, k, v);
30 for (int i=0; i<k; i++) g_cells[v+i] = g_cells[vector_entry (cell_unspecified)];
32 for (int i=0; i<k; i++)
35 SCM z = vector_entry (cell_unspecified);
36 //g_cells[y] = g_cells[z];
51 assert (TYPE (x) == TVECTOR);
52 return MAKE_NUMBER (LENGTH (x));
56 vector_ref (SCM x, SCM i)
58 assert (TYPE (x) == TVECTOR);
59 assert (VALUE (i) < LENGTH (x));
60 SCM e = VECTOR (x) + VALUE (i);
61 if (TYPE (e) == TREF) e = REF (e);
62 if (TYPE (e) == TCHAR) e = MAKE_CHAR (VALUE (e));
63 if (TYPE (e) == TNUMBER) e = MAKE_NUMBER (VALUE (e));
68 vector_entry (SCM x) {
69 if (TYPE (x) == TPAIR || TYPE (x) == TSPECIAL || TYPE (x) == TSTRING || TYPE (x) == TSYMBOL || TYPE (x) == TVECTOR) x = MAKE_REF (x);
74 vector_set_x (SCM x, SCM i, SCM e)
76 assert (TYPE (x) == TVECTOR);
77 assert (VALUE (i) < LENGTH (x));
80 g_cells[VECTOR (x)+VALUE (i)] = g_cells[vector_entry (e)];
82 SCM y = VECTOR (x)+VALUE (i);
83 SCM z = vector_entry (e);
84 //g_cells[y] = g_cells[z];
92 return cell_unspecified;
96 list_to_vector (SCM x)
98 VALUE (tmp_num) = VALUE (length (x));
99 SCM v = make_vector (tmp_num);
101 while (x != cell_nil)
105 g_cells[p++] = g_cells[vector_entry (car (x))];
108 SCM z = vector_entry (car (x));
109 //g_cells[p++] = g_cells[y];
124 vector_to_list (SCM v)
127 for (int i = 0; i < LENGTH (v); i++) {
128 SCM e = VECTOR (v)+i;
129 if (TYPE (e) == TREF) e = REF (e);
130 x = append2 (x, cons (e, cell_nil));