self-reference

self-calling function inside jQuery plugin

独自空忆成欢 提交于 2019-12-12 03:35:40
问题 I am generating a tree (nested UL list) with javascript using the self-calling function below. I might add that it is within a jQuery plugin, if that is at all relevant to the issue (perhaps it might be?). The variable gd contains a json/array sniffed from a filestructure, so it's basically folders and images's names, and some more data (like the self-explainatory isFolder attribute etc.) for (i = 0; i < gd.length; ++i) { is interrupted by the self-call. var drawTree = function(self,parent){

protobuf message holding reference to another message of same type

旧时模样 提交于 2019-12-11 04:17:34
问题 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<Player*> neighbors; }; I want to use protobuf to serialize instances of this class. How would I write a message definition to represent the above structure? 回答1: There is no concept of "reference" in protobuf. Therefore the sanest way to do it would be to: message Player { required string handle = 1; repeated string

A better idiom for referring to base classes from derived classes?

巧了我就是萌 提交于 2019-12-11 02:22:11
问题 Suppose I have a template <typename T> class A : class_with_long_name<T, and_many_other, template_arguments, oh_my_thats_long>, anotherclass_with_long_name<and_many_other, template_arguments_that, are_also_annoying, including_also, T> { ... } Now, in class A's definition, and/or in its methods, I need to refer to the two superclasses (e.g. to access members in the superclass, or types defined in it etc.) However, I want to avoid repeating the superclass names. At the moment, what I'm doing is

Haskell: Handling deadlocked self-referential lists

不打扰是莪最后的温柔 提交于 2019-12-10 21:28:10
问题 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 blocking list" Return [1,1] Explaining 2: it seems possible that when entering the generator to get element N , we could then make all self references inside the generator limited to the list but ending at N-1 (we notice the read N inside the scope generate

Entity Framework Self Referencing Hierarchical Many To Many

本秂侑毒 提交于 2019-12-10 20:17:22
问题 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 I created a ResourceHierarchy table which has two fields, (Parent_ID, Child_ID) and two foreign keys with each one referencing the primary key of the Resource table (ID) and the ResourceHierarchy table has a composite primary key of (Parent_ID,

Infinite self-referencing list

蓝咒 提交于 2019-12-10 18:46:57
问题 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 not . reverse) s1 s3 = s2 ++ [False] ++ (map not . reverse) s2 Generally sn = s(n-1) ++ [0] ++ (map not . reverse) s(n-1) = s0 ++ [0] ++ (f s0) ++ [0] ++ (f (s0 ++ [0] ++ (f s0))) ++ ... where f = (map not . reverse) Attempted Implementation I can

EntityFramework Code First self-referencing one to one (1:1) relationship mapping - Unable to determine the principal end

前提是你 提交于 2019-12-10 16:55:35
问题 I have this class: public class Message { public long Id { get; set; } public string Subject { get; set; } public string Message { get; set; } public virtual Message ParentMessage { get; set; } public virtual Message ChildMessage { get; set; } //... } Using EntityFramework Code First Add-Migration gives me the message: Unable to determine the principal end of an association between the types... I can't use the [Required] attribute, because the first message in this thread will have no parent,

Self-referencing a partial key of a table

青春壹個敷衍的年華 提交于 2019-12-10 11:38:02
问题 I am designing a datatable (-s) for storing the list of shareholders. In case a shareholder is a nominee, it discloses the list of share owners. These all need to have a pile of similar references. Thus, I would like to store all in one table. Nominees are registered shareholders and thus, they have an account number in the system, from which I get the data. Opposed to this, share owners that are coming from nominee disclosure have no their own account number, and share account number of the

A bad interaction between self-referential types and bounded wildcards

帅比萌擦擦* 提交于 2019-12-10 10:12:45
问题 This case seems to be another one where Eclipse's Java compiler crushes javac. The only question for me is whether it's a bug in JLS or javac. interface EndoFunctor< C, FC extends EndoFunctor< C, FC > > { /*...*/ } interface Algebra< C, FC extends EndoFunctor< ? extends C, FC > > { /*...*/ } The second line compiles in Eclipse, but fails to compile in javac with the message that "type parameter FC is not within its bound". FC is declared to extend EndoFunctor< ? extends C, FC >, and the bound

Advice/discussion on anonymous “self referential” data structures

让人想犯罪 __ 提交于 2019-12-10 03:29:11
问题 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 Clojure code to be able to refer to some "intermediate version of whatever data structure I'm in" from within that data structure (a lot like in a let ). Quick examples: => (self-ish {:a 10 :b (inc (this :a)) :c (count (vals this))}) => {:a 10, :b