nested

Nested datatype for square matrices

混江龙づ霸主 提交于 2019-12-04 04:29:55
I am trying to understand how this datatype (Square) represents square matrices. type Square = Square' Nil data Square' t a = Zero (t (t a) ) | Succ (Square' (Cons t) a) data Nil a = Nil data Cons t a = Cons a (t a) So. What is t here? I suppose it is one of the types declared above. I decided to start with the simplest, so Zero (Nil (Nil Int)) If I put integer 4 as a value, is this a matrix (4) ? Suppose it is something. Now, what is this: Succ ( Zero (Cons t) a) if I am right about t , then this, perhaps, must represent some 2×2 matrix, but what are its values? Succ (Zero (Cons Nil) a) I

Nested named list to data frame

家住魔仙堡 提交于 2019-12-04 04:28:21
问题 I have the following named list output from a analysis. The reproducible code is as follows: list(structure(c(-213.555409754509, -212.033637890131, -212.029474755074, -211.320398316741, -211.158815833294, -210.470525157849), .Names = c("wasn", "chappal", "mummyji", "kmph", "flung", "movie")), structure(c(-220.119433774144, -219.186901747536, -218.743319709963, -218.088361753899, -217.338920075687, -217.186050877079), .Names = c("crazy", "wired", "skanndtyagi", "andr", "unveiled", "contraption

How to access an outer member from a nested object literal?

独自空忆成欢 提交于 2019-12-04 04:12:08
In the following code, can the x member be accessed from the nested object literal? var outer = { x : 0, inner: { a : x + 1, // 'x' is undefined. b : outer.x + 1, // 'outer' is undefined. c : this.x + 1 // This doesn't produce an error, } // but outer.inner.c is NaN. } In the way you put it - no. You need two stages construction, this will work: var outer = { x : 0 }; // outer is constructed at this point. outer.inner = { b : outer.x + 1 // 'outer' is defined here. }; Not in the construct you have there, no. The main reason being that outer doesn't actually exist yet when you are inside inner

How to update values in nested dictionary if keys are in a list? [duplicate]

亡梦爱人 提交于 2019-12-04 03:43:59
问题 This question already has answers here : Access nested dictionary items via a list of keys? (16 answers) Closed 11 months ago . Let's say i have a list of keys key_lst = ["key1", "key2", "key3"] and i have a value value = "my_value" and an example dict my_dict with this structure { "key1": { "key2": { "key3": "some_value" } }, } How can I dynamically assign the new value in variable value to my_dict["key1"]["key2"]["key3"] by going thru / looping over my key_lst ? I can not just say my_dict[

Efficient sampling from nested lists

本小妞迷上赌 提交于 2019-12-04 03:29:41
I have a list of lists , containing data.frames, from which I want to select only a few rows . I can achieve it in a for-loop, where I create a sequence based on the amount of rows and select only row indices according to that sequence. But if I have deeper nested lists it doesn't work anymore. I am also sure, that there is a better way of doing that without a loop. What would be an efficient and generic approach to sample from nested lists, that vary in their dimensions and contain data.frames or matrices? ## Dummy Data n1=100;n2=300;n3=100 crdOrig <- list( list(data.frame(x = runif(n1,10,20)

Sort collection by relationship value

南楼画角 提交于 2019-12-04 03:28:33
问题 I want to sort a laravel collection by an attribute of an nested relationship. So I query all projects (only where the project has tasks related to the current user), and then I want to sort the projects by deadline date of the task relationship. Current code: Project.php public function tasks() { return $this->hasMany('App\Models\ProjectTask'); } Task.php public function project() { return $this->belongsTo('App\Models\Project'); } UserController $projects = Project->whereHas('tasks',

How to get a second System.Thread.ThreadPool?

喜你入骨 提交于 2019-12-04 03:25:36
问题 If I use the ThreadPool in a nested way, my application hangs: ThreadPool.QueueUserWorkItem((state) => ThreadPool.QueueUserWorkItem(Action)); How to get a second and independent ThreadPool to achieve nesting? 回答1: There is only one single ThreadPool - it's not something you can (or should) make more than one instance of in an application. I don't recommend doing this, but if you really wanted to, you could use multiple instances of your own ThreadPool implementation, such as SmartThreadPool.

How to declare nested objects in JavaScript?

淺唱寂寞╮ 提交于 2019-12-04 03:17:49
问题 I'm trying to create an object that contains an object, so think of it as a dictionary: var dictionaries = {}; dictionaries.english_to_french = { {english:"hello",french:"bonjour"}, {english:"i want",french:"je veux"}, {english:"bla",french:"le bla"} }; but it gives the error Uncaught SyntaxError: Unexpected token { what am I doing wrong? Thanks ! Edit I'm sorry that I did not clarify what I want to do. Edited the code above. 回答1: You're trying to give your object a property, and that

How do I force nested list items to be the same width as parent list item?

删除回忆录丶 提交于 2019-12-04 03:17:45
I have a horizontal parent list. Some of the list items display a nested vertical list when clicked. How do I force the items in the vertical sub list to be the same width as the parent list item? See jsFiddle . HTML: <ul class="mainMenu horizontalMenu bulletless fullWidth bold"> <li class="showSubMenu"> <div>Resumes & Cover Letters ▾ </div> <ul class="mainSubMenu bulletless"> <li><a>Resumes</a></li> <li><a>Cover Letters</a></li> <li><a>Interviews</a></li> </ul> </li><li><a>Other Link</a> </li><li><a>Other Link</a></li> </ul>​ CSS: .horizontalMenu li{ display: inline-block; } .mainMenu > li{

SQL Server - Nested transactions in a stored procedure

落花浮王杯 提交于 2019-12-04 03:05:05
Lets say this is the situation: [Stored Proc 1] BEGIN BEGIN TRANSACTION ... exec sp 2 COMMIT END Now, if SP 2 - rolls back for whatever reason, does SP 1 - commit or rollback or throw exception? Thanks. There are no autonomous transactions in SQL Server. You may see @@TRANCOUNT increase beyond 1, but a rollback affects the whole thing. EDIT asked to point to documentation. Don't know of the topic that documents this explicitly, but I can show it to you in action. USE tempdb; GO Inner proc: CREATE PROCEDURE dbo.sp2 @trip BIT AS BEGIN SET NOCOUNT ON; BEGIN TRANSACTION; PRINT @@TRANCOUNT; IF