Questions tagged [self-reference]

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Useful Links:

Stanford Encyclopedia 'Self Reference' Entry

Related Tags:

596 questions
3
votes
4 answers

Self referential table and recursive SQL function

I have a category table with: categoryID parentCategoryID categoryName and an items table with: itemID categoryID itemName I am using MySQL. i want to write a query that will return a count of Items in a category given a categoryID. The query…
rodrick
  • 87
  • 2
  • 8
3
votes
2 answers

How do I implement a 'social' aspect with mongoid

I am attempting to create a friend network on a site I am making. I am using Mongoid. How do I instantiate friends? I assume that Users needs to have a relational association with multiple other users. But the following code: class User include…
Ryan
  • 2,102
  • 4
  • 18
  • 23
3
votes
2 answers

What happens when you append a list to itself?

Suppose I ran the program x=[] x.append(x) print(x) I get [[...]] as the output. But what does it mean? Is the list storing pointers and then pointing to itself? Or is it copying itself never quite completely? How is this list stored in…
sebastianspiegel
  • 445
  • 4
  • 12
3
votes
1 answer

Creating self-relation between existing items in loopback

I'm trying to create a model for items that are related to each other. One could think of a twitter-like case where users are following each other. I tried to write the model like this (common/models/user.json): { "name": "user", "base":…
Älhoo
  • 91
  • 1
  • 5
3
votes
2 answers

Convert from self-reference array into nested array in tree

I use angular-bootstrap-nav-tree I have Array that i get from self-reference table Like this: var obj = [ {id:1,label:"Animal"}, {id:2,label:"Vigitable"}, {id:3,label:"Cats",parent:1}, {id:4,label:"black…
Muath
  • 4,351
  • 12
  • 42
  • 69
3
votes
2 answers

Refer to class in C++ macro

I want to write struct Foo{ MY_MACRO }; and have that expand into struct Foo{ void bar(Foo&){} }; How do I define MY_MACRO? The only things I can come up with is the following: #define MY_MARCO(X) void bar(X&){} struct Foo{ …
B.S.
  • 1,435
  • 2
  • 12
  • 18
3
votes
2 answers

How would you implement a Grid in a functional language?

I am interrested in different ways of implementing a constant grid in a functional language. A perfect solution should provide traversal in pesimistic constant time per step and not use imperative constructs (laziness is ok). Solutions not quite…
3
votes
2 answers

Symfony Form render with Self Referenced Entity

I have an Entity containing Self-Referenced mapping. class Category { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** …
benarth
  • 75
  • 4
3
votes
1 answer

Entity Framework Self Referencing Hierarchical Many To Many

OK this problem has it all. Conceptually I have a Resource entity which can have many Child Resources and many Parent Resources. The Resource table has two fields, ID and Name with ID being the primary key. To complete the many to many relationship…
3
votes
1 answer

Defining a graph node variant with cycles in OCaml

I am trying to implement a regex to NFA converter. I have most of the code written, but I am struggling to find a way to build a graph with a cycle given my representation for states (nodes) and edges. My graph representation is as follows: type…
3
votes
3 answers

C++ template class referring to itself

I need to create an MVC architecture, where both the View and the Controller classes have already been written as templates as follows: template class Controller { /* Implement Controller */ }; template
v vv cvvcv
  • 71
  • 1
  • 2
  • 7
3
votes
3 answers

The self parameter with a dictionary of functions within a class

I'm attempting to create a dictionary of executable functions within a class. But having trouble getting the self parameter to work correctly. Consider the following code: class myclass(object): def x(self): return 'x' def y(self): …
Wes Modes
  • 2,024
  • 2
  • 22
  • 40
3
votes
1 answer

How to do conditional formatting using self reference in excel

I want to apply conditional formatting (fill cell with red) to all rows in columns F, I, L. E,F,I,H,L,K columns contain number values. Condition is if F3 < E3 fill F3 with red, I3 < H3 fill I3 with red, L3 < K3 fill L3 with red and so on. It will go…
alwbtc
  • 28,057
  • 62
  • 134
  • 188
3
votes
2 answers

protobuf message holding reference to another message of same type

I have a Player structure which holds a list of pointers to its closest neighbors. The structure might look as follows in C++: struct Player { string handle; vector neighbors; }; I want to use protobuf to serialize instances of this…
Agnel Kurian
  • 57,975
  • 43
  • 146
  • 217