Cadabra
Computer algebra system for field theory problems
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functional.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <functional>
5 #include "Storage.hh"
6 
7 namespace cadabra {
8 
16 
17  void do_list(const Ex& tr, Ex::iterator it, std::function<bool(Ex::iterator)> f);
18 
23 
24  int list_size(const Ex& tr, Ex::iterator it);
25 
31 
32  Ex::iterator do_subtree(const Ex& tr, Ex::iterator it, std::function<Ex::iterator(Ex::iterator)> f);
33 
37 
38  Ex::iterator find_in_list(const Ex& tr, Ex::iterator it, std::function<Ex::iterator(Ex::iterator)> f);
39 
43 
44  Ex::iterator find_in_subtree(const Ex& tr, Ex::iterator it, std::function<bool(Ex::iterator)> f, bool including_head=true);
45 
49 
50  Ex make_list(Ex el);
51 
52 };
Ex::iterator find_in_subtree(const Ex &tr, Ex::iterator it, std::function< bool(Ex::iterator)> f, bool including_head)
Returns an iterator to the first element for which 'f' returns 'true', or 'tr.end()'.
Definition: Functional.cc:56
void do_list(const Ex &tr, Ex::iterator it, std::function< bool(Ex::iterator)> f)
Apply a function on every element of a list, or if the iterator 'it' does not point to a list...
Definition: Functional.cc:6
Ex::iterator do_subtree(const Ex &tr, Ex::iterator it, std::function< Ex::iterator(Ex::iterator)> f)
Apply a function on every node in the tree at and below the given node, depth-first.
Definition: Functional.cc:33
Ex make_list(Ex el)
Ensure that the tree is a list, even if it contains only a single element.
Definition: Functional.cc:98
Ex::iterator find_in_list(const Ex &tr, Ex::iterator it, std::function< Ex::iterator(Ex::iterator)> f)
Returns an iterator to the first element for which 'f' does not return tr.end().
Definition: Functional.cc:81
int list_size(const Ex &tr, Ex::iterator it)
For lists as defined above for 'do_list', return their size (in case you really need to know the size...
Definition: Functional.cc:25