nested

How to print prime numbers up to the user's entered integer?

被刻印的时光 ゝ 提交于 2019-12-02 22:20:09
问题 Good afternoon everyone, I'm currently trying to create a program that does the following: Develop a code that will print all prime numbers up to the user's entered number. An example of the output: Enter an integer (2 or above): 19 The prime numbers up to you integer are: 2 3 5 7 11 13 17 19 Unfortunately, there is also a list of "requirements" that need to be met as well: If the user enters a number below 2, your program should print a message that the number is not valid, and then stop. A

How to read nested JSON structure with a Sencha Touch Data Model?

不想你离开。 提交于 2019-12-02 21:12:26
I've been trying to figure this out all evening but to no avail. I have a JSON structure as follows (coming from another system so I can't change its structure): { "parents":{ "parent":[ { "parentId":1, "children":{ "child":[ { "childId":1, }, { "childId":2, } ] } }, { "parentId":2, "children":{ "child":[ { "childId":1, }, { "childId":2, } ] } } ], "pageNum":1, "pageSize":2 } } However, I can't figure out what the correct structure for the data models should be. I've tried the following but it does not work. BTW, I can access the parent information. The issue is with accessing the child

Nested json to php search listing

£可爱£侵袭症+ 提交于 2019-12-02 21:01:13
问题 I have some json and I want certain this to be listed and when a selection is made I would like the parser to filter out everything else except what was requested, here is my code and I'll give a good explanation of what I need afterwards: <script type="text/javascript"> $(document).ready(function() { var url="/json2php/posts.php"; $.getJSON(url,function(data){ $.each(data.posts,function(i,post) { var content, trackInfo = '', tracks = post.tracks; // loop over the tracks and collect info $

Python recursively replace character in keys of nested dictionary?

百般思念 提交于 2019-12-02 20:27:39
I'm trying to create a generic function that replaces dots in keys of a nested dictionary. I have a non-generic function that goes 3 levels deep, but there must be a way to do this generic. Any help is appreciated! My code so far: output = {'key1': {'key2': 'value2', 'key3': {'key4 with a .': 'value4', 'key5 with a .': 'value5'}}} def print_dict(d): new = {} for key,value in d.items(): new[key.replace(".", "-")] = {} if isinstance(value, dict): for key2, value2 in value.items(): new[key][key2] = {} if isinstance(value2, dict): for key3, value3 in value2.items(): new[key][key2][key3.replace("."

CASE statement in SQLite query

南楼画角 提交于 2019-12-02 19:59:47
Why this query doesn't work? :( I tried to replace nested IF statement "...SET lkey = IF(lkey >= 11, lkey - 5, IF(lkey > 5, lkey + 2,lkey))" UPDATE pages SET lkey = CASE lkey WHEN lkey >= 11 THEN lkey - 5 ELSE CASE lkey WHEN lkey > 5 THEN lkey + 2 ELSE lkey END END, rkey = CASE lkey WHEN lkey >= 11 THEN rkey - 5 ELSE CASE rkey WHEN rkey < 11 THEN rkey + 2 ELSE rkey END END WHERE rkey > 5 AND lkey < 12; The syntax is wrong in this clause (and similar ones) CASE lkey WHEN lkey > 5 THEN lkey + 2 ELSE lkey END It's either CASE WHEN [condition] THEN [expression] ELSE [expression] END or CASE

Accessing Ember-CLI Nested Controllers

丶灬走出姿态 提交于 2019-12-02 19:11:30
问题 This is my directory structure: controllers/ ---- restaurant/ ----items.js ---- index.js ---- restaurant.js And my router declaration: this.route("restaurants",{ path: "/restaurants" }); this.resource("restaurant", { path: "/restaurants/:restaurant_id" }, function() { this.resource("items", { path: "/items" }); }); My Items controller (located in restaurants/items.js) begins with the following: export default Ember.ObjectController.extend({ needs: ["restaurant"], restaurant: Ember.computed

Nesting a (vertical) UIPageViewController inside another (horizontal) UIPageViewcontroller

耗尽温柔 提交于 2019-12-02 18:54:02
I have a big problem with my UIPageViewController . I want to present content in my app using sections and sub-sections. So, I have created "two" instances of UIPageViewController - horizontal (red) and vertical (blue): Earlier I said I have created "two" instances - it is not quite true - there can be tens of instances, but only 2 are presented at the same time, you know what I mean . Both controllers have transitionStyle set to UIPageViewControllerTransitionStyleScroll . The red UIPageViewController is responsible for horizontal scrolling between sections and blue are responsible for

ViewPager with Nested Fragments?

孤人 提交于 2019-12-02 17:21:42
My problem According to the Google's docs: You can now embed fragments inside fragments. This is useful for a variety of situations in which you want to place dynamic and re-usable UI components into a UI component that is itself dynamic and re-usable. For example, if you use ViewPager to create fragments that swipe left and right and consume a majority of the screen space, you can now insert fragments into each fragment page. To nest a fragment, simply call getChildFragmentManager() on the Fragment in which you want to add a fragment. This returns a FragmentManager that you can use like you

Replacing nested if statements

落花浮王杯 提交于 2019-12-02 17:07:31
This is related to a chapter from beautiful code . And in that chapter I read about the nested if s. The author was talking about deeply nested if s as originator of bugs and less readable. And he was talking about replacing nested if s with case statements and decision tables . Can anybody illustrate how to remove nested if s with case ( select case ) and decision tables ? Lasse Vågsæther Karlsen Well, not directly an answer to your question since you specifically ask about switch/case statements, but here is a similar question. Invert “if” statement to reduce nesting This talks about

Diamond with nested for loop in Java

瘦欲@ 提交于 2019-12-02 15:57:44
问题 I am trying to display a diamond of asterisks using nested for loops. Here is my code so far: public class Diamond { public static void main(String[] args) { int size = 9; for (int i = 1; i <= size; i += 2) { for (int k = size; k >= i; k -= 2) { System.out.print(" "); } for (int j = 1; j <= i; j++) { System.out.print("*"); } System.out.println(); }// end loop for (int i = 1; i <= size; i += 2) { for (int k = 1; k <= i; k += 2) { System.out.print(" "); } for (int j = size; j >= i; j--) {