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
8
votes
3 answers

How to refer to itself in the list comprehension?

list_a = [2, 4, 3, 6, 3, 8, 5] list comprehension is very useful. list_b = [a**2 for a in list_a] I want to know how to write a self-reference in the list comprehension. For example: list_c = [a**2 if i == 0 else a*2 + (itself[i-1]) for i, a in…
8
votes
0 answers

Unable to convert Protobuf to map becasue of 'Direct self-reference leading to cycle' error

I am trying to convert a ProtoBuf to Map by using the below mentioned code. Map map = objectMapper.convertValue(obj, Map.class); Sample PB data causing this: id: "1" metadata { type: "UNIT" isValidated: false status { status: ACTIVE …
Rohith CM
  • 119
  • 6
8
votes
3 answers

Const self-referential structures

I'm writing in C. I've defined a new type (noFunc_menuEntry) which is made of a self-referential structure. struct noFunc_menuEntry_tag { const char *text; struct noFunc_menuEntry_tag *up_entry; struct noFunc_menuEntry_tag *down_entry; …
BzFr
  • 83
  • 1
  • 6
8
votes
2 answers

Is adaptive parsing possible in Prolog?

I am attempting to write an adaptive parser in Prolog: in other words, a parser that can modify its own parsing rules at runtime. In order to do this, I'll need to generate new predicates at runtime, but I'm not sure if this is possible. Would it be…
Anderson Green
  • 30,230
  • 67
  • 195
  • 328
8
votes
2 answers

How do I create a table with self-referencing fields in MySQL?

In GTFS, the field parent_station is either from stop_id (self-reference) or NULL. For instance (note that parent_station might be NULL), SELECT stop_id, stop_name, parent_station FROM stops where stop_id='1970324837184617' OR…
SparkAndShine
  • 17,001
  • 22
  • 90
  • 134
8
votes
5 answers

class __init__ (not instance __init__)

Here's a very simple example of what I'm trying to get around: class Test(object): some_dict = {Test: True} The problem is that I cannot refer to Test while it's still being defined Normally, I'd just do this: class Test(object): some_dict…
Ponkadoodle
  • 5,777
  • 5
  • 38
  • 62
8
votes
2 answers

Advice/discussion on anonymous "self referential" data structures

Apologies for any mistaken terminology--I'm quite new to computer science, and I pretty much only know Clojure (but I guess I'd say I know it pretty well). So, I haven't done a ton of research on this, but I've sometimes found it useful when writing…
Omri Bernstein
  • 1,893
  • 1
  • 13
  • 17
7
votes
3 answers

Defining something to itself in C preprocessor

I ran into these lines: #define bool bool #define false false #define true true I don't think I need to say more than "wtf?", but just to be clear: What is the point of defining something to itself? The lines come from clang stdbool.h
klutt
  • 30,332
  • 17
  • 55
  • 95
7
votes
4 answers

DLL unloading itself

Is it possible for a function that is inside a DLL to unload the DLL? I need to do this so I can make sure the DLL is not in use, then write to the DLL's file.
Iron
  • 73
  • 1
  • 1
  • 3
7
votes
2 answers

What is the meaning of [...] in python?

Instead of a list with some objects in it, I get [...] whenever I run my code. I'd like to know what it means, in order to debug my code.
Algunillo
  • 83
  • 5
7
votes
3 answers

C++ Using a reference to the variable being defined

Is the following code valid C++, according to the standard (discounting the ...s)? bool f(T& r) { if(...) { r = ...; return true; } return false; } T x = (f(x) ? x : T()); It is known to compile in the GCC versions…
ShdNx
  • 3,172
  • 5
  • 40
  • 47
7
votes
3 answers

Eager loading of Linq to SQL Entities in a self referencing table

I have 2 related Linq to SQL questions. Please see the image below to see what my Model looks like. Question 1 I am trying to figure how to eager load the User.AddedByUser field on my User class/table. This field is generated from the relationship…
Saajid Ismail
  • 8,029
  • 11
  • 48
  • 56
7
votes
3 answers

What is quine meant for?

So I just came across the term Quine on Wikipedia and cannot figure out what the heck it is meant for. I'm more than confused about it. Are there any real-world uses for it?
tomsseisums
  • 13,168
  • 19
  • 83
  • 145
6
votes
0 answers

Entity Framework cascade delete parent row in self-referenced table

In my MS SQL Server 2008 database I have self-referenced table with categories for hierarchy (ID and ParentID). Table have a self Foreign Key constraint and "Instead of Delete" trigger to perform deleting the full node with its children. To manage…
Korj
  • 61
  • 3
6
votes
7 answers

LinkedList in swift with node as structure

Can anyone tell me how to create a linked-list in swift with node as structure and linked-list as class. I tried to create a node Node with reference to itself and faced a error "value type 'Node' cannot have a stored property that references…
Mohan Patil
  • 71
  • 1
  • 3