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
2
votes
0 answers

Delete Prisma self-referencing (one to many)

I have this prisma schema model Directory { id String @id @default(cuid()) name String? parentDirectoryId String? userId String parentDirectory Directory? @relation("parentDirectoryId",…
2
votes
2 answers

How to avoid infinite loop in zipWith a self reference?

I'd like to create a list data structure that can zipWith that has a better behavior with self reference. This is for an esoteric language that will rely on self reference and laziness to be Turing complete using only values (no user functions).…
Darren Smith
  • 207
  • 1
  • 4
2
votes
1 answer

Why in Python a list self-reference doesn't behave the same way when extended or summed?

This is just a theoretical question and doesn't have any use case I believe. I was playing with lists self reference and I noticed that: >>> l = [] …
Axeltherabbit
  • 680
  • 3
  • 20
2
votes
3 answers

How can I write a self-referential Rust struct with Arc and BufReader?

I'm trying to write this following code for a server: use std::io::{BufReader, BufWriter}; use std::net::TcpStream; struct User<'a> { stream: Arc, reader: BufReader<&'a TcpStream>, writer: BufWriter<&'a TcpStream>, } fn…
cry0genic
  • 544
  • 3
  • 15
2
votes
1 answer

How to set up the classes for a polymorphic, self-referential group of models?

I'm trying to set up an application that includes groups that can be composed of users or existing groups. Examples: Users Andy, Bob, Charlie, and David are in the 1st forwarders group. Users Eddy, Frank, George, Howard, Iggy, and Jack are in the…
2
votes
3 answers

Need a regular expression to match a dynamically-determined repeat count

I need a ruby regexp pattern that matches a string containing a letter (for simplicity say 'a') n times and then n at the end. For example, it should match "aaa3", "aaaa4" etc but not "a2" or "aaa1", etc.
n00b
  • 721
  • 1
  • 7
  • 18
2
votes
1 answer

Find documents with field matching another field WITHOUT aggregation

so I'm working with a system that can only take the query-argument of a .find() query as input, which means that I can not input an iterative script or an aggregation query. However, I need to be able to find all documents that contain in one of…
NewJob
  • 59
  • 3
2
votes
2 answers

how do I add a recursive foreign key to a table?

I have a table like: table: comments, with rows: id, author, content, replyto I would like 'replyto' to reference 'id' in the same table, how would I do that? Many thanks.
fenerlitk
  • 5,414
  • 9
  • 29
  • 39
2
votes
1 answer

C++ variant containing a map of itself

I would like to be able to create a variant that contains a std::map as one of its cases. The ideal would be able to write something like using MyVariant = std::variant
user17789309
2
votes
3 answers

How to produce a self-referencing variable in R (e.g., index levels given returns)?

I have to produce a self-referencing variable (ind) that is grouped by an id and has to fulfill a certain condition (e.g., time >1). Here is a toy example: set.seed(13) dt <- data.frame(id = rep(letters[1:2], each = 4), time = rep(1:4, 2), ret =…
glaucon
  • 190
  • 1
  • 9
2
votes
1 answer

Typescript reference self object keys

I'm trying to build a typescript type which can infer current object's keys and put them as argument of the selfMethod function. Is it possible to reference keys of the current object ? I know self-referencing is not supported in Typescript yet but…
ovesco
  • 41
  • 3
2
votes
1 answer

laravel nova - how to make a self referential model with restriction

I have a laravel model based on the following table: public function up() { Schema::create('things', function (Blueprint $table) { $table->id(); $table->timestamps(); $table->string('label'); …
David J.
  • 1,753
  • 13
  • 47
  • 96
2
votes
0 answers

Is it possible to implement an iterator that owns a lock together with an inner iterator referencing into that lock?

I want to implement something similar to the following: use std::collections::HashMap; use std::collections::hash_map::Keys as HashMapKeys; use std::sync::{Mutex, MutexGuard}; struct MyIterable { data: Mutex>, } struct…
Lancern
  • 403
  • 2
  • 9
2
votes
1 answer

Typescript - how to implement circular generic

I have the following code: interface BaseProps { onEvent: (control: TControl) => void; } class BaseControl> { onBlur = () => { onEvent(this); //subscriber must see the whole TS-class instead of…
2
votes
1 answer

How to do protobuf message cross-referencing?

I use the below protobuf message to represent a tree structure message Foo { uint32 value = 1; repeated Foo children = 3; } Now I want to add two children to a node, I basically do Foo foo; Foo *c1 = foo->add_children(); Foo *c2 =…