core: Remove list_to_string.
[mes.git] / lib.c
1 /* -*-comment-start: "//";comment-end:""-*-
2  * Mes --- Maxwell Equations of Software
3  * Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
4  *
5  * This file is part of Mes.
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 SCM caar (SCM x) {return car (car (x));}
22 SCM cadr (SCM x) {return car (cdr (x));}
23 SCM cdar (SCM x) {return cdr (car (x));}
24 SCM cddr (SCM x) {return cdr (cdr (x));}
25 SCM caaar (SCM x) {return car (car (car (x)));}
26 SCM caadr (SCM x) {return car (car (cdr (x)));}
27 SCM caddr (SCM x) {return car (cdr (cdr (x)));}
28 SCM cdadr (SCM x) {return cdr (car (cdr (x)));}
29 SCM cadar (SCM x) {return car (cdr (car (x)));}
30 SCM cddar (SCM x) {return cdr (cdr (car (x)));}
31 SCM cdddr (SCM x) {return cdr (cdr (cdr (x)));}
32 SCM cadddr (SCM x) {return car (cdr (cdr (cdr (x))));}
33
34 SCM
35 length (SCM x)
36 {
37   int n = 0;
38   while (x != cell_nil)
39     {
40       n++;
41       x = cdr (x);
42     }
43   return MAKE_NUMBER (n);
44 }
45
46 SCM
47 list (SCM x) ///((arity . n))
48 {
49   return x;
50 }
51
52 SCM
53 exit_ (SCM x) ///((name . "exit"))
54 {
55   assert (TYPE (x) == NUMBER);
56   exit (VALUE (x));
57 }