How to use array methods as query condition in cosmosDB SQL query?

I have a query issue using Azure cosmosDB.
Below is a data container.

If I want to query the document which value of status of all the objects in regions array are 1, how to write the query syntax?

Does cosmosDB supports something like array.every(item => item.status === 1)?

Thanks…

{   "1": {     regions: [       {         "id": "region_a",         "status": 1,       },       {         "id": "region_b",         "status": 2,       }     ]   },   "2": {     regions: [       {         "id": "region_a",         "status": 1,       },       {         "id": "region_b",         "status": 1,       }     ]   } } 

How to add condition for 1st Iteration in views-view-fields.html.twig file

I am trying to implement a carousel , inside my views-view-fields–block_1.html.twig , I want to add active class inside the div for the first Iteration . I have added the code in twig file but every time it is adding active class for all the iteration.

code snippet:

{% if fields.counter.content == 1 %} {% set tag = "active" %} {% else %} {% set tag = "" %} {% endif %} 

In my view title,body,image and result counter fields are there . From result counter i am getting the value and comparing inside the above twig file. Can anyone give suggestion, how to achieve this.

Thanks,

Removal of subtrees in tree on condition optimally

i have mini program that removes subtrees of a tree based on following condition: If a subtree is consisting only of nodes with “rank” 1 remove it. I am using recursive DFS approach. Trees or subtrees does not have any further special properties. I want to ask about your opinions. Is it posibble to make this more elegant/more optimal?. Thanks.

public class Main {      public static void main(String[] args) {         List<Node> tree1 = Arrays.asList(             new Node(1, null, 1),             new Node(2, 1, 1),             new Node(3, 1, 1),             new Node(4, 2, 0),             new Node(5, 3, 1),             new Node(6, 5, 0),             new Node(7, 5, 1),             new Node(8, 7, 0),             new Node(9, 5, 1),             new Node(10, 3, 1)         );          List<Node> newTree = new ArrayList<>();         traverse(tree1.get(0), tree1, newTree);         if(tree1.get(0).rank != 1 || tree1.get(0).getNumberOfValidSubtrees() != 0) {             newTree.add(tree1.get(0));         }          System.out.println(tree1);         newTree.sort(Comparator.comparing(Node::getId));         System.out.println(newTree);     }      private static void traverse(Node parent, List<Node> allNodes, List<Node> newTree){         List<Node> children = allNodes.stream().filter(e -> e.parentId != null && e.parentId == parent.id).collect(Collectors.toList());          for(Node child : children) {             traverse(child, allNodes, newTree);              if(child.rank != 1 || child.getNumberOfValidSubtrees() != 0) {                 parent.incrementValidSubtree();                 newTree.add(child);             }         }     } } 

Node class

class Node{     int id;     Integer parentId;      int rank;     private int numberOfValidSubtrees;      Node(int id, Integer parentId, int rank){         this.id = id;         this.parentId = parentId;         this.rank = rank;         this.numberOfValidSubtrees = 0;     }      public int getNumberOfValidSubtrees(){         return this.numberOfValidSubtrees;     }      public void incrementValidSubtree() {         this.numberOfValidSubtrees++;     }      public int getId() {         return id;     }      public String toString() {         return String.valueOf(id);     } } 

Track payment with my custom code in order to prevent race condition between apple-pay notification and my custom bill generation

I want to add subscriptions to my app. I already have the in-app-purchase working but i have a problem, i can’t add a custom code to the payment call to apple payment sdk, so the apple-pay server notification could arrives to my server before my app call my server with the receipt (generated by apple-payment-sdk).

I want to track the payment with my custom code in order to prevent race condition between apple-pay notification and my custom bill generation. Just like the image below

I want this

Others payment gateways like MercadoPago allows this in order to prevent this race condition and allow a easier development experience.

. Show that $X_n \to 0$ in probability under given condition.

Let $ k > 0$ . Suppose that

$ $ \forall \epsilon > 0: \exists N: \forall n \geq N: P(|X_n| \geq \epsilon) \leq \epsilon k$ $

Show that $ X_n \xrightarrow{P}{ 0}$ .

Attempt:

We have to show:

$ $ \forall \tilde{\epsilon} > 0: \lim_n P(|X_n| \geq \tilde{\epsilon}) = 0$ $

This is equivalent with showing that

$ $ \forall \tilde{\epsilon} > 0: \forall \epsilon \in ]0, \tilde{\epsilon}[: \exists N: \forall n \geq N : P(|X_n| \geq \tilde{\epsilon}) \leq \epsilon k$ $

So, let’s show this.

Let $ \tilde{\epsilon} > 0$ and take $ \epsilon \in ]0 , \tilde{\epsilon}[$ . Choose $ N$ such that $ P(|X_n| \geq \epsilon) \leq \epsilon k$ whenever $ n \geq N$ . Then, if $ n \geq N$ , we have

$ $ P(|X_n| \geq \tilde{\epsilon}) \leq P(|X_n| \geq \epsilon) \leq \epsilon k$ $

and the claim follows.

Is this correct?

All elements of a list in a condition

I am going to help Mathematica to satisfy the condition:

If All elements of a matrix's eigenvalues are different from zero, then print "ok"

For matrix={{1, 0}, {2, 0}};  If[Eigenvalues[matrix] != 0, Print@"OK"]  it must print OK 

and For matrix={{1, 0}, {2, 0}} its result is nothing.

How can show All elements of a list in a condition?

Magento 1.9.3.1 – Coupon – set condition calculate cart total on non sale items?

I’ve a client with a request for a coupon that seems to have hit a restriction in what magento 1.9.3.1 can actually do.

We have products that are normal price and ‘special price’/sale items.

The coupon needs a condition where it will only work if there is more than $ 99 in the cart of ‘non sale products’ / so standard products only.

However I cannot work out how to set a condition to do that. It seems the cart total ‘condition attribute’ cant be set to only count ‘normal price items’ and ignore special price products when calculating the total.

The problem is, people are able to put a normal product ($ 70.00) in their cart and then perhaps add a sale item that is listed at sale price ($ 50 / normal price $ 80)

This takes their cart total to : $ 120, with the current condition set, the condition is valid as the cart is over $ 99 requirement.

The problem is, the cart is ‘not’ over $ 99 of normal product total, its only $ 70.

How can I set it so the cart total is calculated on standard items only?

Subset with modified condition, is it still NP-complete?

So i know the conditions required for a problem to be NP-Complete is that it has to lie within NP and has to be NP-hard. The given problem I have is subset sum. However, the conditions have been change to sum ≤ M and sum ≥ M from sum = M. My initial reaction is that the two problems are no longer NP-complete since they can both be solved within polynomial time.

  1. Check each element and see if there exists at least one smaller than M.
  2. Add all positive integers and see if the sum of all elements is larger than M.

Since it isn’t NP Hard, it cannot therefore be NP-complete.

Am I thinking/approaching this correctly?