arrays Questions
3
There are three ways to pass an array to a function
1.
void changeArray(int array[]) {
array[0] = 1111;
}
void changeArrayByPointer(int * array) {
array[0] = 1111;
}
void changeArray(int ...
4
Solved
Consider this:
a = array(1:60, c(3,4,5))
# Extract (*,2,2)^th elements
a[cbind(1:3,2,2)]
# ^^ returns a vector of length 3, c(16, 17, 18)
# Note this is asymptotically inefficient -- cbind(1:k,2...
Browse asked 19/8 at 9:29
2
Solved
I have a 1D numpy numpy array with integers, where I want to replace zeros with the previous non-zero value if and only if the next non-zero value is the same.
For example, an array of:
in: x = n...
Euratom asked 14/1, 2018 at 16:3
8
Solved
Are array of pointers to different types possible in c++?
with example please)
4
Solved
In C I can initialize an array on the stack like so:
SOME_DATA_TYPE* x = (SOME_DATA_TYPE[5]) {v1, v2, v3, v4, v5};
Is there a similar one-line method to assign values to a malloc()-ed array on t...
Houri asked 27/7, 2016 at 19:15
24
Solved
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
Example:
Given nums = [3, 2, 4], target = 6,
Because nums[1] + nums[2] = 2 + 4 = 6
return ...
Cogon asked 18/8, 2019 at 12:53
5
Solved
How can I offset this array so it only outputs every ten numbers?
(0...40)
[10,20,30,40]
5
Solved
How can I query all tables' all table columns in a database?
Method I've tried:
get all table names using select tablename from pg_tables where schemaname = 'public'
Process cmd string using UNI...
Fresher asked 21/8, 2018 at 3:25
4
Solved
hope you can help. I've got an empty array in my project which fill up as certain buttons are pressed (using push()). I want to know when a certain set of elements are in the array.
In the below c...
Deathblow asked 13/7, 2017 at 20:43
3
I'm learning Javascript and I faced a problem with sorting numbers I don't understand how work sorting function and I find an other way to sort the numbers but it was with list not with arrays I ne...
Checker asked 18/6, 2022 at 17:6
13
Solved
$split_point = ' - ';
$string = 'this is my - string - and more';
How can I make a split using the second instance of $split_point and not the first one. Can I specify somehow a right to left sear...
3
Solved
In jq, I can select an item in a list fairly easily:
$ echo '["a","b","c","d","e"]' | jq '.[] | select(. == ("a","c"))'
Or if you prefer to get it as an array:
$ echo '["a","b","c","d","e"]' | ...
5
Solved
I am from a C background and passing an array in C style causes an error.
package main
import "fmt"
func f(a *int){
fmt.Println(a[1])
}
func main(){
var a [100]int
a[1]=100
f(a)
}
Error:: ...
6
The Microsoft site suggests the following code should work:
Dim numbers = {{1, 2}, {3, 4}, {5, 6}}
However I get a complile error when I try to use it in an excel VBA module.
The following does w...
4
Solved
Hi Is possible to calculate EMA in javascript?
The formula for EMA that I'm trying to apply is this
EMA = array[i] * K + EMA(previous) * (1 – K)
Where K is the smooth factor:
K = 2/(N + 1)...
Tropopause asked 15/10, 2016 at 8:52
4
Solved
I want to be able to modify my array of objects using map in Swift of the fly, without looping through each element.
Before here were able to do something like this (Described in more details here...
Indolent asked 28/3, 2016 at 11:50
5
Solved
I have an arr variable which looks as below:
const arr = [undefined, undefined, 'hello', 'hello', 'hi'];
I want to print out the first non-null value from within the arr array variable.
In above a...
Inmost asked 7/1, 2021 at 6:45
2
In Java we can initialize an array using following code:
data[10] = {10,20,30,40,50,60,71,80,90,91};
How can we do this in Pascal?
Sherrard asked 10/11, 2015 at 5:28
7
Solved
Julia appears to have a lot of Matlab like features. I'd like to select from an array using a predicate. In Matlab I can do this like:
>> a = 2:7 ;
>> a > 4
ans =
0 0 0 1 1 1
&g...
8
I want to setup a grid containing m * n objects. This grid got a width of m rows and n columns.
I tried this code first
let map = [][]; // Create an array that takes a x and y index
function cre...
Phox asked 1/5, 2018 at 9:37
6
Solved
I am a Ruby programmer who has ended up developing a code generate for C. Its like asking a Limo to tow a 1960s truck. Any way.
Here is what I thought should work but doesnt work.
float[][] pixel...
4
Solved
I want to do something similar to what was asked here NumPy array, change the values that are NOT in a list of indices, but not quite the same.
Consider a numpy array:
> a = np.array([0.2, 5.6...
3
Solved
I want to know if two or more arrays have common items, but I don't care what those items are. I know lodash has an _.intersection method, but I don't need it to run through every single item of ea...
Holcombe asked 2/4, 2015 at 15:13
9
Solved
Here is the code I have so far:
public static int mode(int[][] arr) {
ArrayList<Integer> list = new ArrayList<Integer>();
int temp = 0;
for(int i = 0; i < arr.length; i ++) {
f...
7
Solved
When I'm sorting my array I get the following error in console:
Uncaught TypeError: Cannot read property 'localeCompare' of null
What I've tried so far:
HTML:
<table class="table table tabl...
Wallraff asked 5/10, 2015 at 10:51
© 2022 - 2024 — McMap. All rights reserved.