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
1 answer

Deserialize self referencing objects with Jackson

I have a JSON string looking like that (simplified): [ { "id":1, "friends":[2] }, { "id":2, "friends":[1,3] }, { "id":3, "friends":[] } ] The content of friends are ids of other users in the list. Is it possible somehow to create a Java class…
3
votes
2 answers

pass self class reference to child class

In C# 4.0 (or earlier if it can be done), how does a parent class pass a reference of itself to a child class. For example: class Book { public string bookname = "a"; public static List pages = new List(); static void…
Eugene
  • 10,957
  • 20
  • 69
  • 97
3
votes
1 answer

Self-Reference One-to-One mapping in Hibernate

I have a class A which has a property type indicating whether it is a receipt or a delivery. A receipt can be mapped to a single delivery and vice-versa. Now consider that the receipt transaction and the delivery transaction are siblings. So class A…
blaks
  • 113
  • 3
  • 14
3
votes
2 answers

Tool to produce self-referential programs?

Many results in computability theory (such as Kleene's second recursion theorem) ensure that it is possible to construct programs that can operate over their own source code. For example, in Michael Sipser's "Introduction to the Theory of…
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
3
votes
2 answers

Is there a way to self reference a data.table in i

Consider the standard data.table syntax DT[i, j, ...]. Since .SD is only defined in j and NULL in i, is there any way to implicitly (desired) or explicitly (via something like .SD) refer to the current data.table in a function in i? Use Case I would…
mnist
  • 6,571
  • 1
  • 18
  • 41
3
votes
1 answer

Ruby on Rails: Retrieving a friendship given two users

I have seen the railscast on self-referential relationships here: http://railscasts.com/episodes/163-self-referential-association I have built upon this in that I've included a 'status' field on friendships so that friendships must be requested and…
Adam
  • 131
  • 9
3
votes
2 answers

Julia: Self-referential and recursive types

What I am trying to do is not very straight forward, maybe it is easier if I start with the result and then explain how I am trying to get there. I have a struct with two fields: struct data{T} point::T mat::Array end What I would like to…
3
votes
3 answers

Self-Referencing C Struct

Can you have a structure in C that has elements of that same structure? My first attempt at implementing a binary search tree in C is the following: #include struct binary_tree_node { int value; struct binary_tree_node *left =…
dvanaria
  • 6,593
  • 22
  • 62
  • 82
3
votes
0 answers

How to links and refer to self in swagger docs?

If I have a doc/api endpoint that should point to the current swagger doc, how should the self-referring be done for Swagger with OpenAPI 3.0.0? For example, given openapi: 3.0.0 servers: - url: http://hello-world.com info: description: |- …
alvas
  • 115,346
  • 109
  • 446
  • 738
3
votes
3 answers

Why do we use pointers in self referential structs?

Why do we use pointers in self-referential structs? It is obligatory or not? If not, what advantages does us having a pointer to struct in struct versus normal struct definition give? typedef struct _Struct { struct _Struct* next; // do we really…
Anton Barinov
  • 183
  • 1
  • 3
  • 13
3
votes
1 answer

Spring static self-reference class pattern use cases

I recently stumbled upon a code like the one below. @Component public class Instance { private static Instance instance; private final Template template; public Instance(Template template) { this.template = template; …
Rauno
  • 616
  • 8
  • 22
3
votes
2 answers

Haskell: Handling deadlocked self-referential lists

Is there any useful reason why the GHC allows the following to block forever: list = 1 : tail list It seems with a bit of sophistication in the list iterator/generator we should be able to do something more useful: Return error "Infinitely…
Erik
  • 87
  • 3
3
votes
2 answers

Understanding Swift Closure Capturing

I have gone through Swift Closures and ARC in Swift and I got little confused. I have simple scenario of calling web service and using response data. Here is my basic implementation: class WebServices: NSObject { func…
D4ttatraya
  • 3,344
  • 1
  • 28
  • 50
3
votes
2 answers

Help with self-referencing model & view in Rails 3

I have a simple Client table (or model) where a Client can have a Parent Client (only one, or none). I modeled it this way: class Client < ActiveRecord::Base belongs_to :parent, :class_name => 'Client', :foreign_key => 'parent_id’ end That seems…
3
votes
4 answers

Infinite self-referencing list

Problem I'm trying to implement the modified Dragon Curve from AoC Day 16 as an infinite list in Haskell. The list is composed of True and False. We start with some list s0: s1 = s0 ++ [False] ++ (map not . reverse) s0 s2 = s1 ++ [False] ++ (map…