summaryrefslogtreecommitdiff
path: root/web/reduce/rweb/appl/list2vector.ch
blob: cb6df64e337a83b42b5517cc425a70bdc0625710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
% Copyright (c) 1991 Marcel Roelofs, University of Twente, Enschede,
% The Netherlands.
%
% $Header: list2vector.ch,v 1.2 91/10/23 09:37:31 roelofs Exp $
%
@x
One should be aware of the fact that the standard REDUCE token reader
|token1| is not able to recognize and return a vector as a token.
However, on our system |token1| has been replaced by a token reader
based on the lisp underneath REDUCE, which \`{\i}s able to read
vectors. Moreover, on another configuration at our site which did use
|token1| as the token reader, we could patch it in such way that it
was also able to read vectors without too much difficulty.

The implementation of |save_liebracket| beneath explicitly uses the
fact that the token reader used is able to read vectors. If this is
not the case |save_liebracket| has to be rewritten in such a way that
all commutators to be saved are temporarily stored on a list which can
be read by |token1|. In that case the vector structure has to be build
up again. This case will be dealt with in a separate change file
belonging to this package.

The procedure |save_liebracket| has to be available in algebraic mode. 

@d print_this_property_of(bracketname)=@/
<<prin2 "put('"; prin1 bracketname; prin2 ",'"; prin1 property; prin2 ",'"; 
  prin1 get(bracketname,property); prin2 ")$"; terpri(); terpri()>> @;

@u
lisp operator save_liebracket;
lisp procedure save_liebracket(bracketname,savefile);
begin scalar generatorname;
  check_if_bracketname_is_a_liebracket_in("SAVE_LIEBRACKET:");@/
  generatorname:=get(bracketname,'generatorname);@/
  rmsubs();
  out savefile;@/
  write "lisp$"; %Reading the properties should be done in symbolic mode%
  terpri(); terpri();@/ 
  @<Check if this package has been loaded@>;
  for each property in 'klist . list_of_properties_of_a_liebracket do
    print_this_property_of(bracketname);@/
  write "flag('(",bracketname,"),'full)$"; terpri(); terpri();
  for each property in 'klist . list_of_properties_of_a_generator do
    print_this_property_of(generatorname);
  @<Incorporate statements to repair the |vector_structure|@>;
  write "algebraic$ end$";@/
  shut savefile;
end$
@y
One should be aware of the fact that the standard REDUCE token reader
|token1| is not able to recognize and return a vector as a token.
However, on our system |token1| has been replaced by a token reader
based on the lisp underneath REDUCE, which \`{\i}s able to read
vectors. Moreover, on another configuration at our site which did use
|token1| as the token reader, we could patch it in such way that it
was also able to read vectors without too much difficulty.

Here, however, we will give an implementation for those systems which have
|token1| as their token reader, or which have another token reader
uncapable of reading vectors. This means that we have to transform the
vectors |info_list| and |vector_structure| into a list and a list of
lists, respectively, hence have to be dealt with separately.

The procedure |save_liebracket| has to be available in algebraic mode. 

@d print_this_property_of(bracketname)=@/
<<prin2 "put('"; prin1 bracketname; prin2 ",'"; prin1 property; prin2 ",'"; 
  prin1 get(bracketname,property); prin2 ")$"; terpri(); terpri()>> @;

@u
lisp operator save_liebracket;
lisp procedure save_liebracket(bracketname,savefile);
begin scalar generatorname,vector_list;
  check_if_bracketname_is_a_liebracket_in("SAVE_LIEBRACKET:");@/
  generatorname:=get(bracketname,'generatorname);@/
  rmsubs();
  out savefile;@/
  write "lisp$"; %Reading the properties should be done in symbolic mode%
  terpri(); terpri();@/ 
  @<Check if this package has been loaded@>;
  for each property in 'klist . cddr list_of_properties_of_a_liebracket do
    print_this_property_of(bracketname);@/
  @<Save the vectors |vector_structure| and |info_list| as lists@>;
  write "flag('(",bracketname,"),'full)$"; terpri(); terpri();
  for each property in 'klist . list_of_properties_of_a_generator do
    print_this_property_of(generatorname);
  @<Incorporate statements to repair the |vector_structure|@>;
  write "algebraic$ end$";@/
  shut savefile;
end$

@ With the above procedures saving the vectors |vector_structure| and
|info_list| as lists and reading these lists in as vectors is peanuts.
The procedures |list2vector| and |vector2list| are already available
in PSL, for which this changefile is meant primarily.

@<Save the vectors ...@>=
vector_list:=for each el in vector2list get(bracketname,'vector_structure) 
  collect vector2list el;
prin2 "put('"; prin1 bracketname; 
prin2 ",'VECTOR_STRUCTURE,list2vector(for each el in '"; 
prin1 vector_list; prin2 " collect list2vector el))$"; terpri(); terpri();
vector_list:=vector2list get(bracketname,'info_list);
prin2 "put('"; prin1 bracketname; prin2 ",'INFO_LIST,list2vector '"; 
  prin1 vector_list; prin2 ")$"; terpri(); terpri()

@z