nested

How can I combine multiple nested Substitute functions in Excel?

瘦欲@ 提交于 2019-12-04 02:52:11
问题 I am trying to set up a function to reformat a string that will later be concatenated. An example string would look like this: Standard_H2_W1_Launch_123x456_S_40K_AB Though sometimes the " S " doesn't exist, and sometimes the "40K" is "60K" or not there, and the "_AB" can also be "_CD" or _"EF". Finally, all underscores need to be changed to hyphens. The final product should look like this: Standard-H2-W1-Launch-123x456- I have four functions that if ran one after the other will take care of

Convert an array to a list of nested objects - Eloquent Javascript 4.3

大憨熊 提交于 2019-12-04 02:29:54
问题 I am looking at this exercise from the book Eloquent Javascript, Chapter 4 - A List for quite some time and I'm trying to understand how this particular function works: function arrayToList(array) { let list = null; for (let i = array.length - 1; i >= 0; i--) { list = {value: array[i], rest: list}; } return list; } console.log( arrayToList([10, 20])); // → {value: 10, rest: {value: 20, rest: null}} Even after adding the list to the Watch window in the Debugger I can't clearly see the

Sending nested FormData on AJAX

爱⌒轻易说出口 提交于 2019-12-04 02:00:16
I need to send some data using ajax and FormData, because I want to send a file and some other parameters. The way I usually send data is this: $.ajax({ type: 'POST', url: 'some_url', dataType: 'json', processData:false, contentType:false, data:{ Lvl_1-1: 'something', Lvl_1-2: 'something', Lvl_1-3: { Lvl_1-3-1: "something", Lvl_1-3-2: "something", Lvl_1-3-3: "something", }, }, ... }); If I don't use FormData(), I have no problem, but when using FormData(), only the data on Lvl1 is ok, but anything nested is displayed as string like this <b>array</b> <i>(size=3)</i> 'Lvl1-1' <font color='

in python, how do i iterate a nested dict with a dynamic number of nests?

混江龙づ霸主 提交于 2019-12-04 01:41:19
OK by dynamic I mean unknown at runtime. here is a dict: aDict[1]=[1,2,3] aDict[2]=[7,8,9,10] aDict[n]=[x,y] I don't know how many n will be but I want to loop as follows: for l1 in aDict[1]: for l2 in aDict[2]: for ln in aDict[n]: # do stuff with l1, l2, ln combination. Any suggestions on how to do this? I am relatively new to python so please be gentle (although I do program in php). BTW I am using python 3.1 You need itertools.product . from itertools import product for vals in product(*list(aDict.values())): # vals will be (l1, l2, ..., ln) tuple Same idea as DrTyrsa, but making sure order

Return from nested Android PreferenceScreen to previous PreferenceScreen

ε祈祈猫儿з 提交于 2019-12-03 21:55:17
I am programmatically creating a nested set of PreferenceScreen s. When the user dives into one of these screens, and taps something in there, I want to go back to the previous PreferenceScreen , (i.e. the "parent"). I couldn't find any information on this, and calling finish() doesn't do the job but rather returns from ALL the PreferenceScreen s instead of just one. I just meet the problem and just found the solution. You can override the method onPreferenceTreeClick in PreferenceActivity. call the param preferenceScreen's getDialog method, then call the dialog's dismiss method. just like

SASS variables and inheritance

痴心易碎 提交于 2019-12-03 21:55:07
问题 Suppose I have two virtually identical HTML structures, but with different class names. They only differ by a few variables, like width and height . By using SASS/SCSS variables I thought I could do something like this: .widget-a { $width: 50px; } .widget-b { $width: 100px; } .widget-a, .widget-b { button { background: red; width: $width; } } This would let me write a single piece of SASS nested code for both widgets a and b. However, variables are only visible inside a nested scope, so SASS

Object-like attribute access for nested dictionary

£可爱£侵袭症+ 提交于 2019-12-03 21:45:43
问题 I'm utilising a package which returns a nested dictionary. It feels awkward to access this return object in my class methods with the dictionary syntax, when everything else is in object syntax. Searching has brought me to the bunch / neobunch packages, which seems to achieve what I'm after. I've also seen namedtuples suggested but these do not easily support nested attributes and most solutions rely on using dictionaries within the namedtuple for nesting. What would be a more natural way of

Scheme - Map function for applying a function to elements in a nested list

99封情书 提交于 2019-12-03 21:38:49
I'm trying to write a mapping function in scheme that applies a function to each value in a nested list. For example, (map number? '(3 (2 A) 2 Z) should return (#t (#t #f) #t #f) Here's what I have so far: (define (map fun lst) (if (null? lst) '() (if (list? (car lst)) (cons (map fun (car lst)) (map fun (cdr lst))) (cons (fun (car lst)) (map fun (cdr lst)))))) It works if the nested list is at the front of the list. For example (map number? '((3 A) 2 Z)) correctly returns ((#t #f) #t #f) The problem occurs when the nested list occurs after another element in the original list. For example (map

Nested models of the same 'class' in the Backbone.js framework?

情到浓时终转凉″ 提交于 2019-12-03 21:38:40
I'm new to Backbone. Is it possible to define a Model in backbone which contains a list of Models of the same type? Example: MyModel = Backbone.Model.extend({ initialize: function() { nestedMyModels:new Array(); }, addMyModel: function(aModel) { // Code here would push() aModel onto array }, render: function() { // Loop through array calling render() recursively } }); I would then have a View which started a recursive call to render(). Example: MyView = Backbone.View.extend({ render:function() { this.model.render(); } }); 1 no arrays but Collections Always that you think in an Array of Models

searching a nested javascript object, getting an array of ancestors

北战南征 提交于 2019-12-03 21:29:09
I have a nested array like this: array = [ { "id": "67", "sub": [ { "id": "663", }, { "id": "435", } ] }, { "id": "546", "sub": [ { "id": "23", "sub": [ { "id": "4", } ] }, { "id": "71" } ] } ] I need to find 1 nested object by its id and get all its parents, producing an array of ids. find.array("71") => ["546", "71"] find.array("4") => ["546", "23", "4"] What's the cleanest way to do this? Thanks. Recursively: function find(array, id) { if (typeof array != 'undefined') { for (var i = 0; i < array.length; i++) { if (array[i].id == id) return [id]; var a = find(array[i].sub, id); if (a != null