Solved

sort list

Posted on 2011-03-14
6
221 Views
Last Modified: 2012-05-11
Hello, I have a list(double type). I want to know if all items are greater than 1 or less than 1 at the same time, then a flag is raised.
For ex,
0.7776
0.8121
1.27

Open in new window

Some are <1, the other >1. than I got false.
0.3492
0.3945

Open in new window

I should get a true.
Thanks.
0
Comment
Question by:zhshqzyc
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 35130462
bool greaterThanOne = yourList.Exists(num=>num > 1);
0
 
LVL 22

Expert Comment

by:p_davis
ID: 35130474
sorry it should be reversed.


bool greaterThanOne = !yourList.Exists(num=>num > 1);
0
 

Author Comment

by:zhshqzyc
ID: 35130578
NO, YOU MISUNDERSTOOD MY QUESTION.
I mean if all great than 1 or all less than 1. I shou get true. The data go the the same direction, towards to >1 or <1.
If mixed direction then get false.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 62 total points
ID: 35130583
I think it'd be more along the lines of (take note that there is only 1 ampersand):

bool result = theList.Any(item => item > 1) & theList.Any(item => item < 1);

Open in new window

0
 
LVL 22

Assisted Solution

by:p_davis
p_davis earned 63 total points
ID: 35130595
bool same = !yourList.Exists(num=> num < 1 && num > 1);
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 35130599
In light of the recent post, modify it to this:
bool result = !(theList.Any(item => item > 1) & theList.Any(item => item < 1));

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now