arrays

TCL - Parse JSON to hash/array

帅比萌擦擦* 提交于 2021-02-16 15:36:06
问题 I'm new in TCL, I have an JSON string, and I want to parse it to something I can use it easily like hash/ array which similar like in Perl or Java to loop the data and print it. But I've found many sources to help me, but it is very less and still couldn't get it. And I try something like this: #!/usr/bin/tclsh proc dict2json {dictVal} { # XXX: Currently this API isn't symmetrical, as to create proper # XXX: JSON text requires type knowledge of the input data set json "" dict for {key val}

VBA Excel - How to display non equal values in an excel array

折月煮酒 提交于 2021-02-16 15:31:13
问题 So currently I have two DATA inputs in excel Data 1 and Data 2 I need a formula or some sort to display results *currently this is a manual process. 回答1: Approach using Filter() function Function test(ByVal a, ByVal b, Optional Delim$ = ",") As String 'Purpose: return non unique values by comparing two comma separated string lists a vs. b a = Split(a, Delim): b = Split(b, Delim) Dim elem For Each elem In b a = Filter(a, elem, False) ' Include:=False, i.e. exclude non uniques Next elem test =

Extract integers from string and add them in Java [duplicate]

我与影子孤独终老i 提交于 2021-02-16 15:25:06
问题 This question already has answers here : how to extract numeric values from input string in java (16 answers) Closed 4 years ago . I want to extract the integers from string and add them. Ex : String s="ab34yuj789km2"; I should get the output of integers from it as 825 ( i.e., 34 + 789 + 2 = 825 ) 回答1: Here's one way, by using String.split: public static void main(String[] args) { String s="ab34yuj789km2"; int total = 0; for(String numString : s.split("[^0-9]+")) { if(!numString.isEmpty()) {

How to fix Trying to access array offset on value of type null error

↘锁芯ラ 提交于 2021-02-16 15:24:05
问题 I am creating a time table view using PHP, in which I am getting the lecture data according to the day and time. Here is the code which I have did $monday_lectures = "SELECT * from lectures where lecture_time = '11am to 1pm' and lecture_day = 'firday'"; $result_11to1 = mysqli_query($con, $monday_lectures); $m11to1 = mysqli_fetch_array($result_11to1); if ($m11to1["lecture_day"] == !'') { echo "<td>".$m11to1["lecture_name"]."</td>"; } else { echo "<td> no class</td>"; } But I am getting below

Recursively Search in Array with a For Loop

感情迁移 提交于 2021-02-16 15:18:12
问题 I know there are better ways to search an array, but I really want to understand how to return when the value is found in a recursive call. Logging when found isn't a problem, but I can't seem to make this return true when found. The problem is basic. Fully search multi-dimensional array for a value and return true if found or false if not found, using a for loop and recursion. I've tried returning the recursive function and everything else I can think of, but nothing works fully. function

Generate all possible string combinations by replacing the hidden “#” number sign

半城伤御伤魂 提交于 2021-02-16 15:00:07
问题 My task is to generates all possible combinations of that rows without the hidden # square. The input is XOXX#OO#XO and here is the example of what the output should be: XOXXOOOOXO XOXXOOOXXO XOXXXOOOXO XOXXXOOXXO I am only allowed to solve this solution iteratively and I am not sure how to fix this and have been working on this code for a week now.. any help would be much appreciated! Here is my code: import java.lang.Math; public class help { public static void main(String[] args) { String

Accessing array elements in c

纵然是瞬间 提交于 2021-02-16 14:54:11
问题 Below is the code on compiling this code in codeblocks I get the following error message: 1 value required as increment operator . Now I know that arr++ is not working but I want to know why. #include<stdio.h> int main() { int arr[5]={1,2,3,4,5},i; for(i=0;i<5;i++) { printf("%d\n",*arr); arr++; } return 0; } 回答1: arr++ is not working but i want to know why? arr stores the base address that is &arr[0] therefore, arr always points to the starting position of the array and can't be changed .

how to count and print out only duplicates?

こ雲淡風輕ζ 提交于 2021-02-16 14:28:31
问题 I know how to go through whole array, but I only need number of duplicate occurrences. I'm at beginners level, so just basic use of loops and arrays. int[] array = {12, 23, -22, 0, 43, 545, -4, -55, 43, 12, 0, -999, -87}; for (int i = 0; i < array.length; i++) { int count = 0; for (int j = 0; j < array.length; j++) { count++; } System.out.println(array[i] + "\toccurs\t" + count + "X"); } 回答1: You can do better if you use more than just loops and arrays, but a simple algorithm would be to use

How to split consecutive elements in a list into sublists

无人久伴 提交于 2021-02-16 14:28:26
问题 I have the following list: indices_to_remove: [0,1,2,3,..,600,800,801,802,....,1200,1600,1601,1602,...,1800] I have basically 3 subsets of consecutive indices: 0-600 800-1200 1600-1800 I would like to create 3 different small lists that will include only consecutive numbers. Expected outcome: indices_to_remove_1 : [0,1,2,3,....,600] indices_to_remove_2 : [800,801,802,....,1200] indices_to_remove_3 : [1600,1601,1602,....., 1800] P.S: The numbers are arbitrary and random; moreover, I may

how to count and print out only duplicates?

一世执手 提交于 2021-02-16 14:28:07
问题 I know how to go through whole array, but I only need number of duplicate occurrences. I'm at beginners level, so just basic use of loops and arrays. int[] array = {12, 23, -22, 0, 43, 545, -4, -55, 43, 12, 0, -999, -87}; for (int i = 0; i < array.length; i++) { int count = 0; for (int j = 0; j < array.length; j++) { count++; } System.out.println(array[i] + "\toccurs\t" + count + "X"); } 回答1: You can do better if you use more than just loops and arrays, but a simple algorithm would be to use