FAUST compiler  0.9.9.6b8
Typedefs | Functions | Variables
list.hh File Reference
#include "symbol.hh"
#include "tree.hh"
#include <stdio.h>
Include dependency graph for list.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef Tree(* tfun )(Tree)
 

Functions

void print (Tree t, FILE *out=stdout)
 
Tree cons (Tree a, Tree b)
 
Tree list0 ()
 
Tree list1 (Tree a)
 
Tree list2 (Tree a, Tree b)
 
Tree list3 (Tree a, Tree b, Tree c)
 
Tree list4 (Tree a, Tree b, Tree c, Tree d)
 
Tree hd (Tree l)
 
Tree tl (Tree l)
 
bool isNil (Tree l)
 
bool isList (Tree l)
 
Tree nth (Tree l, int i)
 
Tree replace (Tree l, int i, Tree e)
 
int len (Tree l)
 
Tree reverse (Tree l)
 
Tree reverseall (Tree l)
 
Tree rconcat (Tree l1, Tree l2)
 
Tree concat (Tree l1, Tree l2)
 
Tree lrange (Tree l, int i, int j)
 
Tree lmap (tfun f, Tree l)
 
bool isElement (Tree e, Tree l)
 
Tree addElement (Tree e, Tree l1)
 
Tree remElement (Tree e, Tree l1)
 
Tree singleton (Tree l)
 
Tree list2set (Tree l)
 
Tree setUnion (Tree l1, Tree l2)
 
Tree setIntersection (Tree l1, Tree l2)
 
Tree setDifference (Tree l1, Tree l2)
 
Tree left (Tree t)
 
Tree right (Tree t)
 
Tree pushEnv (Tree key, Tree val, Tree env=nil)
 
bool searchEnv (Tree key, Tree &v, Tree env)
 
void setProperty (Tree t, Tree key, Tree val)
 
bool getProperty (Tree t, Tree key, Tree &val)
 
void remProperty (Tree t, Tree key)
 
Tree tmap (Tree k, tfun f, Tree t)
 
Tree substitute (Tree t, Tree id, Tree val)
 

Variables

Sym CONS
 
Sym NIL
 
Tree nil
 

Typedef Documentation

typedef Tree(* tfun)(Tree)

Definition at line 118 of file list.hh.

Function Documentation

Tree addElement ( Tree  e,
Tree  l1 
)

Definition at line 272 of file list.cpp.

References addElement(), cons(), hd(), isList(), and tl().

Referenced by addElement(), evalIdDef(), list2set(), and ppsig::printrec().

273 {
274  if (isList(l)) {
275  if (e < hd(l)) {
276  return cons(e,l);
277  } else if (e == hd(l)) {
278  return l;
279  } else {
280  return cons(hd(l), addElement(e,tl(l)));
281  }
282  } else {
283  return cons(e,nil);
284  }
285 }
Tree addElement(Tree e, Tree l)
Definition: list.cpp:272
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree nil
Definition: list.cpp:116
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree concat ( Tree  l1,
Tree  l2 
)

Definition at line 216 of file list.cpp.

References rconcat(), and reverse().

Referenced by applyList(), and sigCartesianProd().

217 {
218  return rconcat(reverse(l), q);
219 }
Tree reverse(Tree l)
Definition: list.cpp:240
Tree rconcat(Tree l, Tree q)
Definition: list.cpp:210

Here is the call graph for this function:

Here is the caller graph for this function:

Tree cons ( Tree  a,
Tree  b 
)
inline
bool getProperty ( Tree  t,
Tree  key,
Tree val 
)

Definition at line 423 of file list.cpp.

References CTree::getProperty().

Referenced by addLayerDef(), annotate(), evalIdDef(), getBoxType(), getColorProperty(), Occurrences::getCount(), getDefFileProp(), getDefLineProp(), getDefNameProperty(), getEvalProperty(), getNumericProperty(), getPMProperty(), getPropagateProperty(), getRecursivness(), ScalarCompiler::getSharingCount(), DocCompiler::getSharingCount(), getSigNickname(), getSigOrder(), privatisation(), searchIdDef(), shcount(), sigMap(), sigMapRename(), subst(), and tmap().

424 {
425  CTree* pl = t->getProperty(key);
426  if (pl) {
427  val = pl;
428  return true;
429  } else {
430  return false;
431  }
432 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree getProperty(Tree key)
Definition: tree.hh:173

Here is the call graph for this function:

Here is the caller graph for this function:

Tree hd ( Tree  l)
inline

Definition at line 133 of file list.hh.

References CTree::branch().

Referenced by addElement(), Description::addGroup(), addKey(), applyList(), boxlistOutputs(), buildBoxAbstr(), checkRulelist(), Klass::closeLoop(), collectDocEqns(), DocCompiler::compileLateq(), SchedulerCompiler::compileMultiSignal(), VectorCompiler::compileMultiSignal(), ScalarCompiler::compileMultiSignal(), concatPath(), copyEnvReplaceDefs(), eval2double(), eval2int(), evalPatternList(), evalRuleList(), SourceReader::expandrec(), ffrestype(), findKey(), formatDefinitions(), ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), Compiler::generateMacroInterfaceElements(), ScalarCompiler::generateNumEntry(), Compiler::generateUserInterfaceElements(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateVSlider(), getBoxType(), getDefFileProp(), getSubSignals(), DocCompiler::getUIDir(), DocCompiler::getUIDocInfos(), infereFFType(), infereSigOrder(), infereSigType(), isBoxNumeric(), isCons(), isElement(), larg2par(), list2set(), list2vec(), makeDefinition(), makeSubFolderChain(), OccMarkup::mark(), normalizePath(), nth(), numericBoxSimplification(), position(), prepareRule(), Compiler::prepareUserInterfaceTree(), boxpp::print(), envpp::print(), printdoccontent(), ppsig::printlabel(), ppsig::printlist(), printlist(), printRule(), printSignal(), pushMultiClosureDefs(), putSubFolder(), rconcat(), recdraw(), remElement(), removeKey(), replace(), reverse(), revEvalList(), rmap(), searchEnv(), setDifference(), setIntersection(), setSigListNickName(), setUnion(), ScalarCompiler::sharingAnalysis(), DocCompiler::sharingAnalysis(), sigToGraph(), standardArgList(), treelist2siglist(), typeAnnotation(), updateKey(), and fullvisitor::visitList().

133 { return l->branch(0); }
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

bool isElement ( Tree  e,
Tree  l 
)

Definition at line 262 of file list.cpp.

References hd(), isList(), and tl().

263 {
264  while (isList(l)) {
265  if (hd(l) == e) return true;
266  if (hd(l) > e) return false;
267  l = tl(l);
268  }
269  return false;
270 }
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

bool isList ( Tree  l)
inline
bool isNil ( Tree  l)
inline

Definition at line 137 of file list.hh.

References CTree::arity(), and CTree::node().

Referenced by Description::addGroup(), addKey(), applyList(), boxlistOutputs(), buildBoxAbstr(), buildBoxAppl(), checkRulelist(), Klass::closeLoop(), concatPath(), copyEnvReplaceDefs(), evalIdDef(), evalPatternList(), evalRuleList(), SourceReader::expandrec(), findKey(), formatDefinitions(), Compiler::generateMacroInterfaceElements(), Compiler::generateUserInterfaceElements(), getBoxType(), getSubSignals(), DocCompiler::getUIDir(), Loop::hasRecDependencyIn(), infereSigOrder(), infereSigType(), isEnvBarrier(), larg2par(), list2vec(), makeDefinition(), makeSubFolderChain(), normalizePath(), position(), preparePattern(), Compiler::prepareUserInterfaceTree(), boxpp::print(), ppsig::printlabel(), ppsig::printlist(), printlist(), printRule(), privatisation(), pushMultiClosureDefs(), putSubFolder(), removeKey(), revEvalList(), setDifference(), setIntersection(), setSigListNickName(), setUnion(), sigMap(), sigMapRename(), subst(), tmap(), treelist2siglist(), updateKey(), and fullvisitor::visitList().

137 { return (l->node() == Node(NIL)) && (l->arity() == 0) ; }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const Node & node() const
return the content of the tree
Definition: tree.hh:143
Sym NIL
Definition: list.cpp:113
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144

Here is the call graph for this function:

Tree left ( Tree  t)
inline

Definition at line 170 of file list.hh.

References CTree::branch().

Referenced by Description::addGroup(), addKey(), evalRule(), findKey(), Compiler::generateUserInterfaceTree(), printRule(), removeKey(), and updateKey().

170 { return t->branch(0); }
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

Here is the caller graph for this function:

int len ( Tree  l)

Definition at line 198 of file list.cpp.

References isList(), and tl().

Referenced by checkRulelist(), evalCase(), ffarity(), ScalarCompiler::generateRec(), DocCompiler::generateRec(), make_pattern_matcher(), makeDefinition(), Symbol::Symbol(), symlistVisit(), and typeAnnotation().

199 {
200  int n = 0;
201  while (isList(l)) { l = tl(l); n++; }
202  return n;
203 }
bool isList(Tree l)
Definition: list.hh:138
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree list0 ( )
inline

Definition at line 126 of file list.hh.

References nil.

Referenced by list1().

126 { return nil; }
Tree nil
Definition: list.cpp:116

Here is the caller graph for this function:

Tree list1 ( Tree  a)
inline

Definition at line 127 of file list.hh.

References cons(), and list0().

Referenced by list2(), sigCartesianProd(), and singleton().

127 { return cons (a, list0()); }
Tree list0()
Definition: list.hh:126
Tree cons(Tree a, Tree b)
Definition: list.hh:124

Here is the call graph for this function:

Here is the caller graph for this function:

Tree list2 ( Tree  a,
Tree  b 
)
inline

Definition at line 128 of file list.hh.

References cons(), and list1().

Referenced by list3().

128 { return cons (a, list1(b)); }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree list1(Tree a)
Definition: list.hh:127

Here is the call graph for this function:

Here is the caller graph for this function:

Tree list2set ( Tree  l)

Definition at line 307 of file list.cpp.

References addElement(), hd(), isList(), nil, and tl().

308 {
309  Tree s = nil;
310  while (isList(l)) {
311  s = addElement(hd(l),s);
312  l = tl(l);
313  }
314  return s;
315 }
Tree addElement(Tree e, Tree l)
Definition: list.cpp:272
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree nil
Definition: list.cpp:116
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Tree list3 ( Tree  a,
Tree  b,
Tree  c 
)
inline

Definition at line 129 of file list.hh.

References cons(), and list2().

Referenced by list4().

129 { return cons (a, list2(b, c)); }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree list2(Tree a, Tree b)
Definition: list.hh:128

Here is the call graph for this function:

Here is the caller graph for this function:

Tree list4 ( Tree  a,
Tree  b,
Tree  c,
Tree  d 
)
inline

Definition at line 130 of file list.hh.

References cons(), and list3().

Referenced by boxHSlider(), boxNumEntry(), boxVSlider(), sigHSlider(), sigNumEntry(), and sigVSlider().

130 { return cons (a, list3(b, c, d)); }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree list3(Tree a, Tree b, Tree c)
Definition: list.hh:129

Here is the call graph for this function:

Here is the caller graph for this function:

Tree lmap ( tfun  f,
Tree  l 
)

Definition at line 247 of file list.cpp.

References reverse(), and rmap().

Referenced by preparePattern(), prepareRule(), and prepareRules().

248 {
249  return reverse(rmap(f,l));
250 }
Tree reverse(Tree l)
Definition: list.cpp:240
static Tree rmap(tfun f, Tree l)
Definition: list.cpp:233

Here is the call graph for this function:

Here is the caller graph for this function:

Tree lrange ( Tree  l,
int  i,
int  j 
)

Definition at line 221 of file list.cpp.

References cons(), nil, and nth().

222 {
223  Tree r = nil;
224  int c = j;
225  while (c>i) r = cons( nth(l,--c), r);
226  return r;
227 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree nil
Definition: list.cpp:116
Tree nth(Tree l, int i)
Definition: list.cpp:182

Here is the call graph for this function:

Tree nth ( Tree  l,
int  i 
)

Definition at line 182 of file list.cpp.

References hd(), isList(), nil, and tl().

Referenced by ffargtype(), ffname(), ScalarCompiler::generateFFun(), DocCompiler::generateFFun(), ScalarCompiler::generateRec(), DocCompiler::generateRec(), isBoxHSlider(), isBoxNumEntry(), isBoxVSlider(), isSigHSlider(), isSigNumEntry(), isSigVSlider(), lrange(), boxpp::print(), and symlistVisit().

183 {
184  while (isList(l)) {
185  if (i == 0) return hd(l);
186  l = tl(l);
187  i--;
188  }
189  return nil;
190 }
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree nil
Definition: list.cpp:116
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

void print ( Tree  t,
FILE *  out = stdout 
)

Definition at line 154 of file list.cpp.

References CTree::arity(), CTree::branch(), isDouble(), isInt(), isPointer(), isSym(), name(), CTree::node(), print(), and printlist().

Referenced by addLayerDef(), evalerror(), evalremark(), evalwarning(), ScalarCompiler::generateCode(), generateInsideSchema(), infereSigOrder(), infereSigType(), print(), printlist(), and printSignal().

155 {
156  int i; double f; Sym s; void* p;
157 
158  if (printlist(t, out)) return;
159 
160  Node n = t->node();
161  if (isInt(n, &i)) fprintf (out, "%d", i);
162  else if (isDouble(n, &f)) fprintf (out, "%f", f);
163  else if (isSym(n, &s)) fprintf (out, "%s", name(s));
164  else if (isPointer(n, &p)) fprintf (out, "#%p", p);
165 
166  int k = t->arity();
167  if (k > 0) {
168  char sep = '[';
169  for (int i=0; i<k; i++) {
170  fputc(sep, out); sep = ',';
171  print(t->branch(i), out);
172  }
173  fputc(']', out);
174  }
175 }
static bool printlist(Tree l, FILE *out)
Definition: list.cpp:123
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isDouble(const Node &n)
Definition: node.hh:143
bool isSym(const Node &n)
Definition: node.hh:199
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
Symbols are unique objects with a name stored in a hash table.
Definition: symbol.hh:53
bool isPointer(const Node &n)
Definition: node.hh:216
bool isInt(const Node &n)
Definition: node.hh:126
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145
void print(Tree t, FILE *out)
Definition: list.cpp:154

Here is the call graph for this function:

Here is the caller graph for this function:

Tree pushEnv ( Tree  key,
Tree  val,
Tree  env = nil 
)

Definition at line 351 of file list.cpp.

References cons().

Referenced by realPropagate(), and sigMapRename().

352 {
353  return cons (cons(key,val), env);
354 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124

Here is the call graph for this function:

Here is the caller graph for this function:

Tree rconcat ( Tree  l1,
Tree  l2 
)

Definition at line 210 of file list.cpp.

References cons(), hd(), isList(), and tl().

Referenced by concat().

211 {
212  while (isList(l)) { q = cons(hd(l),q); l = tl(l); }
213  return q;
214 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree remElement ( Tree  e,
Tree  l1 
)

Definition at line 287 of file list.cpp.

References cons(), hd(), isList(), nil, remElement(), and tl().

Referenced by remElement().

288 {
289  if (isList(l)) {
290  if (e < hd(l)) {
291  return l;
292  } else if (e == hd(l)) {
293  return tl(l);
294  } else {
295  return cons(hd(l), remElement(e,tl(l)));
296  }
297  } else {
298  return nil;
299  }
300 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree remElement(Tree e, Tree l)
Definition: list.cpp:287
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree nil
Definition: list.cpp:116
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

void remProperty ( Tree  t,
Tree  key 
)

Definition at line 434 of file list.cpp.

435 {
436  exit(1); // fonction not implemented
437 }
Tree replace ( Tree  l,
int  i,
Tree  e 
)

Definition at line 192 of file list.cpp.

References cons(), hd(), replace(), and tl().

Referenced by replace().

193 {
194  return (i==0) ? cons(e,tl(l)) : cons( hd(l), replace(tl(l),i-1,e) );
195 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree hd(Tree l)
Definition: list.hh:133
Tree replace(Tree l, int i, Tree e)
Definition: list.cpp:192
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree reverse ( Tree  l)

Definition at line 240 of file list.cpp.

References cons(), hd(), isList(), nil, and tl().

Referenced by applyList(), collectDocEqns(), concat(), ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), ScalarCompiler::generateNumEntry(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateVSlider(), DocCompiler::getUIDir(), lmap(), make_pattern_matcher(), printdoccontent(), and printPatternError().

241 {
242  Tree r = nil;
243  while (isList(l)) { r = cons(hd(l),r); l = tl(l); }
244  return r;
245 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree nil
Definition: list.cpp:116
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree reverseall ( Tree  l)

Definition at line 252 of file list.cpp.

References isList(), reverseall(), and rmap().

Referenced by reverseall().

253 {
254  return isList(l) ? rmap(reverseall, l) : l;
255 }
Tree reverseall(Tree l)
Definition: list.cpp:252
static Tree rmap(tfun f, Tree l)
Definition: list.cpp:233
bool isList(Tree l)
Definition: list.hh:138

Here is the call graph for this function:

Here is the caller graph for this function:

Tree right ( Tree  t)
inline

Definition at line 171 of file list.hh.

References CTree::branch().

Referenced by Description::addGroup(), evalRule(), findKey(), Compiler::generateMacroInterfaceElements(), Compiler::generateMacroInterfaceTree(), Compiler::generateUserInterfaceElements(), Compiler::generateUserInterfaceTree(), Compiler::prepareUserInterfaceTree(), and printRule().

171 { return t->branch(1); }
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

Here is the caller graph for this function:

bool searchEnv ( Tree  key,
Tree v,
Tree  env 
)

Definition at line 356 of file list.cpp.

References hd(), isList(), and tl().

Referenced by realPropagate(), and sigMapRename().

357 {
358  while (isList(env)) {
359  if (hd(hd(env)) == key) {
360  v = tl(hd(env));
361  return true;
362  }
363  env = tl(env);
364  }
365  return false;
366 }
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree setDifference ( Tree  l1,
Tree  l2 
)

Definition at line 336 of file list.cpp.

References cons(), hd(), isNil(), setDifference(), and tl().

Referenced by setDifference().

337 {
338  if (isNil(A)) return A;
339  if (isNil(B)) return A;
340  if (hd(A) == hd(B)) return setDifference(tl(A),tl(B));
341  if (hd(A) < hd(B)) return cons(hd(A), setDifference(tl(A),B));
342  /* (hd(A) > hd(B)*/ return setDifference(A,tl(B));
343 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree hd(Tree l)
Definition: list.hh:133
bool isNil(Tree l)
Definition: list.hh:137
Tree setDifference(Tree A, Tree B)
Definition: list.cpp:336
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree setIntersection ( Tree  l1,
Tree  l2 
)

Definition at line 327 of file list.cpp.

References cons(), hd(), isNil(), setIntersection(), and tl().

Referenced by Loop::hasRecDependencyIn(), and setIntersection().

328 {
329  if (isNil(A)) return A;
330  if (isNil(B)) return B;
331  if (hd(A) == hd(B)) return cons(hd(A), setIntersection(tl(A),tl(B)));
332  if (hd(A) < hd(B)) return setIntersection(tl(A),B);
333  /* (hd(A) > hd(B)*/ return setIntersection(A,tl(B));
334 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree hd(Tree l)
Definition: list.hh:133
Tree setIntersection(Tree A, Tree B)
Definition: list.cpp:327
bool isNil(Tree l)
Definition: list.hh:137
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

void setProperty ( Tree  t,
Tree  key,
Tree  val 
)
Tree setUnion ( Tree  l1,
Tree  l2 
)

Definition at line 317 of file list.cpp.

References cons(), hd(), isNil(), setUnion(), and tl().

Referenced by Loop::absorb(), realeval(), setUnion(), and symlistVisit().

318 {
319  if (isNil(A)) return B;
320  if (isNil(B)) return A;
321 
322  if (hd(A) == hd(B)) return cons(hd(A), setUnion(tl(A),tl(B)));
323  if (hd(A) < hd(B)) return cons(hd(A), setUnion(tl(A),B));
324  /* hd(A) > hd(B) */ return cons(hd(B), setUnion(A,tl(B)));
325 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree hd(Tree l)
Definition: list.hh:133
bool isNil(Tree l)
Definition: list.hh:137
Tree setUnion(Tree A, Tree B)
Definition: list.cpp:317
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree singleton ( Tree  l)

Definition at line 302 of file list.cpp.

References list1().

Referenced by VectorCompiler::generateLoopCode(), and symlistVisit().

303 {
304  return list1(e);
305 }
Tree list1(Tree a)
Definition: list.hh:127

Here is the call graph for this function:

Here is the caller graph for this function:

Tree substitute ( Tree  t,
Tree  id,
Tree  val 
)

Definition at line 525 of file list.cpp.

References subst(), and substkey().

526 {
527  return subst (t, substkey(t,id,val), id, val);
528 }
static Tree substkey(Tree t, Tree id, Tree val)
Definition: list.cpp:483
static Tree subst(Tree t, Tree propkey, Tree id, Tree val)
Definition: list.cpp:493

Here is the call graph for this function:

Tree tl ( Tree  l)
inline

Definition at line 134 of file list.hh.

References CTree::branch().

Referenced by addElement(), Description::addGroup(), addKey(), applyList(), boxlistOutputs(), buildBoxAbstr(), checkRulelist(), Klass::closeLoop(), collectDocEqns(), DocCompiler::compileLateq(), SchedulerCompiler::compileMultiSignal(), VectorCompiler::compileMultiSignal(), ScalarCompiler::compileMultiSignal(), concatPath(), copyEnvReplaceDefs(), VectorCompiler::CS(), decorateSchema::draw(), evalPatternList(), evalRuleList(), SourceReader::expandrec(), findKey(), formatDefinitions(), ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), Compiler::generateMacroInterfaceElements(), ScalarCompiler::generateNumEntry(), Compiler::generateUserInterfaceElements(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateVSlider(), getBoxType(), getDefLineProp(), getSubSignals(), DocCompiler::getUIDir(), infereFFType(), infereSigOrder(), infereSigType(), initialRecType(), isBefore(), isCons(), isElement(), larg2par(), len(), list2set(), list2vec(), makeDefinition(), makeSubFolderChain(), OccMarkup::mark(), normalizePath(), nth(), position(), prepareRule(), Compiler::prepareUserInterfaceTree(), boxpp::print(), envpp::print(), printdoccontent(), ppsig::printlabel(), ppsig::printlist(), printlist(), printRule(), printSignal(), pushMultiClosureDefs(), putSubFolder(), rconcat(), recdraw(), remElement(), removeKey(), replace(), reverse(), revEvalList(), rmap(), searchEnv(), setDifference(), setIntersection(), setSigListNickName(), setUnion(), ScalarCompiler::sharingAnalysis(), DocCompiler::sharingAnalysis(), sigToGraph(), standardArgList(), treelist2siglist(), typeAnnotation(), updateKey(), and fullvisitor::visitList().

134 { return l->branch(1); }
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

Tree tmap ( Tree  k,
tfun  f,
Tree  t 
)

Definition at line 445 of file list.cpp.

References CTree::arity(), CTree::branch(), getProperty(), isNil(), CTree::node(), setProperty(), tmap(), and tree().

Referenced by tmap().

446 {
447  //printf("start tmap\n");
448  Tree p;
449 
450  if (getProperty(t, key, p)) {
451 
452  return (isNil(p)) ? t : p; // truc pour eviter les boucles
453 
454  } else {
455 
456  tvec br;
457  int n = t->arity();
458  for (int i = 0; i < n; i++) {
459  br.push_back( tmap(key, f, t->branch(i)) );
460  }
461 
462  Tree r1 = tree(t->node(), br);
463 
464  Tree r2 = f(r1);
465  if (r2 == t) {
466  setProperty(t, key, nil);
467  } else {
468  setProperty(t, key, r2);
469  }
470  return r2;
471  }
472 }
vector< Tree > tvec
Definition: tree.hh:90
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isNil(Tree l)
Definition: list.hh:137
Tree tmap(Tree key, tfun f, Tree t)
Definition: list.cpp:445
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
Tree tree(const Node &n)
Definition: tree.hh:186
void setProperty(Tree t, Tree key, Tree val)
Definition: list.cpp:418
Tree nil
Definition: list.cpp:116
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145
bool getProperty(Tree t, Tree key, Tree &val)
Definition: list.cpp:423

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

Sym CONS

Definition at line 112 of file list.cpp.

Sym NIL

Definition at line 113 of file list.cpp.

Tree nil