File: basic.gel

package info (click to toggle)
genius 1.0.27-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 25,308 kB
  • sloc: ansic: 75,620; xml: 71,565; sh: 4,445; makefile: 1,927; lex: 523; yacc: 298; perl: 54
file content (20 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Basic set theory functions for Genius

# FIXME: Genius should really implement native set type

SetHelp ("Union", "sets", "Returns a set theoretic union of X and Y (X and Y are vectors pretending to be sets)");
function Union(X,Y) =
  (
   for x in X do
    if not IsIn(x,Y) then Y@(elements(Y)+1)=x;
   Y
  )

SetHelp ("MakeSet", "sets", "Returns a set where every element of X appears only once");
function MakeSet(X) =
  (
   S = null;
   for x in X do
    if not IsIn(x,S) then S@(elements(S)+1)=x;
   S
  )