[Solved] why delegate work as ref? [closed]

You can change the method like that: public class Util { public static T[] Transform<T>(T[] values, Transformer<T> t) { return values.Select(x => t(x)).ToArray(); } } Then you can call it like var result = Utils.Transform(values, Square); If you can’t change that method, then you need to copy the array before calling: var result = values.ToArray(); … Read more

[Solved] Parsing a char inside an if c#

There are some issues with your code. First, you do an assignment operation and not equality (single = vs ==) Secondly, if you have a string and want to check if one of his characters is space, you could do: string myString = “This is a string”; foreach (var c in myString) { if (c … Read more

[Solved] A class inside of a class [closed]

Yes you can do that but it would be better if you make the Males and Females into different classes and just inherit from the Human class. class Human: def __init__(self, height, weight): self.height = height self.weight = weight class Male(Human): def __init__(self, name): Human.__init__(self, height, weight) # This will inherit every attribute of the … Read more

[Solved] group given list elements using certain criteria

The only thing I could think of was to iterate over all polygons, and then loop over all the other polygons to find intersections. (Which means the algorithm has a quadratic run time complexity.) Inefficient, but it gets the job done. result = [] for i, shape in enumerate(polys): intersected_shapes = [poly for poly in … Read more

[Solved] VB.net get date from string [closed]

@Pᴇʜ Regex pattern shared in the comment works perfectly per your examples. Here is how to use it with an in cell function. Don’t Forget to add the reference to “Microsoft VBScript Regular Expressions 5.5“ Function simpleCellRegex(Myrange As Range) As String Dim regEx As New RegExp Dim strPattern As String Dim strInput As String Dim … Read more

[Solved] insert tokenized strings from a table to other [closed]

If FULLNAME always consists of 3 parts (which is what you said), then it is relatively simple, using the REGEXP_SUBSTR regular expression function: SQL> with test (fullname) as 2 (select ‘Metro Goldwyn Mayer’ from dual 3 ) 4 select regexp_substr(fullname, ‘\w+’, 1, 1) first_name, 5 regexp_substr(fullname, ‘\w+’, 1, 2) middle_name, 6 regexp_substr(fullname, ‘\w+’, 1, 3) … Read more

[Solved] Excel Grouping (or using SQL) [closed]

” So created a SQL report to generate data that looks like this:” The reason for your downvotes is likely due to you not posting the SQL code here. Leaves me guessing at your table formats, so for my ease… select * from mytable is what I’ll guess you’ve used. I’m left guessing column names … Read more

[Solved] Determining CSS Specificity Score [duplicate]

W3C specification states: A selector’s specificity is calculated as follows: count the number of ID selectors in the selector (= a) count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b) count the number of type selectors and pseudo-elements in the selector (= c) ignore the universal selector Selectors inside … Read more

[Solved] delete the last items of an array [closed]

Could use array_shift / array_unshift, but since the logic seems upside down, you could use something like <?php $apparentDB = array(“1” => “Jason” , “2” => “Jimmy” , “3” => “Christopher” , “4” => “Bruce” , “5” => “james” , “6” => “Mike” , “7” => “Brad” ); /* You can add it one by … Read more

[Solved] Fetching Lowest and Highest Time of the Day from Array

using reduce makes it fairly simple const timings = [{ monday: { from: “12:00”, to: “13:00” }, tuesday: { from: “11:00”, to: “13:00” }, thursday: { from: “11:00”, to: “13:00” }, friday: { from: “11:00”, to: “13:00” }, saturday: { from: “11:00”, to: “13:00” }, }, { monday: { from: “10:00”, to: “17:00” }, tuesday: … Read more

[Solved] Comparing two files in perl [closed]

the code maybe looks like this: #!/usr/bin/perl use strict; use warnings; my @array = (‘1′,’2′,’3′,’5′,’6’); my @array2 = (‘1’, ‘3’, ‘7’, ‘6’); for my $item(@array2) { if (grep($_ == $item, @array) > 0) { print “$item, Match\n”; } else { print “$item, Not Match\n”; } } Output 1, Match 3, Match 7, Not Match 6, … Read more

[Solved] ORDER_BY date LIMIT 1 [duplicate]

First of all, you should use prepared statements like this: $note = “SELECT * FROM notify WHERE seeker=:seeker AND donor=:donor ORDER BY `date` DESC LIMIT 1”; $st = $conn->prepare($note); $st->execute(array( ‘:seeker’ => $_SESSION[’email’], ‘:donor’ => $email, ); Without the place holders you’re still open to SQL injection. Second, you can’t compare a string with an … Read more

[Solved] Match two object keys and display another object key value in angular 4

Use array find: var languages = [ {“name”: “english”, “iso_639_2_code”: “eng”}, {“name”: “esperanto”,”iso_639_2_code”: “epo”}, {“name”: “estonian”,”iso_639_2_code”: “est”} ]; var user = [{name: “john”,language: “eng”,country: “US”}]; var language = languages.find(l => l.iso_639_2_code === user[0].language); var languageName = language && language.name; // <– also prevent error when there is no corresponding language found console.log(languageName); EDIT: With multiple … Read more