Files
secondo/Algebras/Array/arraytest

91 lines
2.3 KiB
Plaintext
Raw Normal View History

2026-01-23 17:03:45 +08:00
#This file is part of SECONDO.
#Copyright (C) 2004, University in Hagen, Department of Computer Science,
#Database Systems for New Applications.
#SECONDO is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#SECONDO is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with SECONDO; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Array von Objekten vom Kind DATA
(delete ad);
(create ad : (array date));
(update ad := ((array date) ("2003-01-30" "2003-01-31" "2003-02-01")));
(query (size ad));
# Array von Relationen
(delete ar);
(create ar : (array(rel(tuple((no int))))));
(update ar := ( (
array(rel(tuple((no int))))
)
(
( (1) )
( (2) (3) )
( (4) (5) (6) )
( (7) (8) (9) (10) )
)
)
)
(query (consume (feed (get ar 3))));
(query (consume (feed (get (put ar ((rel(tuple((no int)))) ((1) (2) (3) (4))) 3) 3))));
(query (consume (feed (get (put ar (get ar 3) 0) 0))));
# Zweidimensionales Array von Integer-Werten
(delete ta);
(create ta : (array(array int)));
(update ta := ((array(array int)) ((1 2 3) (4 5 6))));
(query (get (get ta 1) 2));
(query (put ta (put (get ta 1) 9 2) 1));
# Distribute und Summarize
(delete tenTest);
(create tenTest : (rel(tuple((no int)(na string)))));
(update tenTest := ((rel(tuple((no int)(na string))))
((1 "One")(2 "Two")(3 "Three")(4 "Four")(5 "Five")
(6 "Six")(7 "Seven")(8 "Eight")(9 "Nine")(10 "Ten"))));
(delete prel);
(let prel =
(distribute
(extend
(feed tenTest)
((mod2 (fun (tuple1 TUPLE) (mod (attr tuple1 no) 2)))))
mod2));
# Besser lesbar ist die Form
# let prel = tenTest feed extend[mod2 : .no mod 2] distribute[mod2];
(query (consume (summarize prel)));