max

Find max value of two (or more) properties in list

て烟熏妆下的殇ゞ 提交于 2021-01-27 05:59:17
问题 This question has been asked in one or the other way on SO but not like this. I just came over a very basic issue where I was looking for a statisfying solution :-) I got a list of objects which have two integer properties. Now I want to find the max value of both properties of all object in the list. I came up with three solutions: First approach: int max = Math.Max(list.Max(elem => elem.Nr), list.Max(elem => elem.OtherNr)); Second approach: public int Max(List<Thing> list) { int maxNr = 0;

Find max value of two (or more) properties in list

感情迁移 提交于 2021-01-27 05:58:50
问题 This question has been asked in one or the other way on SO but not like this. I just came over a very basic issue where I was looking for a statisfying solution :-) I got a list of objects which have two integer properties. Now I want to find the max value of both properties of all object in the list. I came up with three solutions: First approach: int max = Math.Max(list.Max(elem => elem.Nr), list.Max(elem => elem.OtherNr)); Second approach: public int Max(List<Thing> list) { int maxNr = 0;

Scheme: Remove the maximum from a BST

筅森魡賤 提交于 2021-01-20 12:18:06
问题 Good afternoon everyone, I have very odd question and I'm sorry If I have posted in a wrong part of the forum. I'm trying to understand remove-max function (provided bellow) from a BST written in scheme, but I have a hard time grasping the ideas in it. I know the Scheme syntax, however there is a lot of going on in this function and thus I am a bit confused. (define removemax-BST (lambda (T) (cond ((null? (caddr t)) (cons (cadr t) (car t)) (else (let ((r (removemax-BST (caddr t)))) (cons

how to get top 3 values in php array and their index

你离开我真会死。 提交于 2021-01-20 04:28:26
问题 I want to get the highest value, the second highest value and the third highest value For example, I have an array like: $n = array(100,90,150,200,199,155,15,186); I know the method to get the max value and its index: echo max($n); //200 $maxs = array_keys($n, max($n)); echo $maxs[0]; //3 I want to get the top 3 values and their index like : value: 200, 199, 186 index:3,4,7 How can i get them? 回答1: Try this: $n = array(100,90,150,200,199,155,15,186); rsort($n); $top3 = array_slice($n, 0, 3);

3DS Max、Maya、SoftImage、houdini对比

Deadly 提交于 2021-01-09 09:09:07
这个话题貌似很经典,我也只是说说自己的看法,然后有一些东西希望大家能够给我解惑让我把这个对比写的更丰富全面。 我是一个接触三维动画制作软件没有几个月的新手,在开始学习之前,因为害怕选错了软件,我花了大量的时间查阅了网上很多大牛写的对比文章,并且把这四款软件都装在我的电脑上试用,现在把自己的一些想法写在这里,希望能给其他新手一点参考。 (新学者的心理很好理解,没人愿意自己辛辛苦苦学了一半发现选了个快被淘汰的软件吧,那该是多么悲剧的一件事。不得不说之前各种Maya和Max对比的言论几乎一片倒的赞誉Maya,对Max多有偏见,也让我非常犹豫Max是不是一个快被淘汰的软件) 我学三维制作软件的目的是为了做游戏,所以在反复比较之后,我最终还是选择了Max。 在我接触过houdini一段时间之后,我强烈建议一个对三维动画有兴趣的程序员认真学下houdini,多一门手艺倒是次要的,关键是那种节点式的操作理念和思想非常值得学习(很多大牛建议程序员去学学lisp正是出于学习其思想和理念的目的),用某人的话来说,学过houdini是不会后悔的。而且对接触过linux编程的程序员来说,这个软件也许不那么难,反倒非常亲切。 首先先把结论放在这里。 ==============================================================

How to get the max date per month

烂漫一生 提交于 2021-01-08 09:46:36
问题 I have a table like kunnr date posnr 30001 28/5/2017 1 30001 25/5/2017 2 30001 15/5/2017 3 30001 25/4/2017 4 30001 20/4/2017 5 30002 15/5/2017 6 30002 25/4/2017 7 I want for every new kunnr to get the record with the max date per month, namely the max for May and max for April etc. OK, I will sort the table loop at it and for every new kunnr .... how I will get the record for max date for each month? Thanks in advance Elias PS: sth went wrong and I realise that I do not get what I want. I

Renaming a column entry when it is the maximum value by group

妖精的绣舞 提交于 2021-01-07 01:38:14
问题 I have a dataset as follows: library(data.table) DT <- structure(list(State_Ab = c("MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD"), County = c("Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore"), year = c(1994, 1994, 1998, 1998, 2000, 2000, 2004, 2004, 2006, 2006, 2010, 2010, 2016, 2016), Population = c(140942, 219673, 235413,

Renaming a column entry when it is the maximum value by group

蓝咒 提交于 2021-01-07 01:32:51
问题 I have a dataset as follows: library(data.table) DT <- structure(list(State_Ab = c("MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD"), County = c("Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore"), year = c(1994, 1994, 1998, 1998, 2000, 2000, 2004, 2004, 2006, 2006, 2010, 2010, 2016, 2016), Population = c(140942, 219673, 235413,

Renaming a column entry when it is the maximum value by group

為{幸葍}努か 提交于 2021-01-07 01:32:30
问题 I have a dataset as follows: library(data.table) DT <- structure(list(State_Ab = c("MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD", "MD"), County = c("Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore", "Baltimore"), year = c(1994, 1994, 1998, 1998, 2000, 2000, 2004, 2004, 2006, 2006, 2010, 2010, 2016, 2016), Population = c(140942, 219673, 235413,

Renaming a column entry, when it is the maximum value by group, gives inconsistent results

岁酱吖の 提交于 2021-01-07 01:26:49
问题 I have data as follows: library(data.table) DT <- structure(list(State_Ab = c("VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA", "VA"), year = c(1995, 1995, 1995, 1995, 1999, 1999, 1999, 1999, 2001, 2001, 2001, 2001, 2005, 2005, 2005, 2005, 2007, 2007, 2007, 2007, 2011, 2011,