Array Comprehension with a random output in Julia

This question is an extension if one I asked earlier today. Basically, I am trying to write an array comprehension in Julia that calls a function f(x) whose output is a random number. When a random number less than 0.5 is reached, I want it to kill t...
more »

2017-05-21 23:05 (5) Answers

Handling JSON single object and array

I'm using Newtonsoft.Json to work with some JSON data that is being returned to me. Depending on what I request I can either get back something that looks like: { "TotalRecords":2, "Result": [ { "Id":24379, "AccountName":...
more »

2017-05-21 20:05 (2) Answers

C++ Image filtering algorithm

I'm busy trying to implement an image filtering algorithm that works as follows: A filter is a 2-dimensional array of size N (N has to be an odd number), therefore having N*N elements. An example filter of size 3 would be: 0.25 1 0.25 0.25 0 0.25 0....
more »

2017-05-21 18:05 (1) Answers

Killing a For loop in Julia array comprehension

I have the following line of code in Julia: X=[(i,i^2) for i in 1:100 if i^2%5==0] Basically, it returns a list of tuples (i,i^2) from i=1 to 100 if the remainder of i^2 and 5 is zero. What I want to do is, in the array comprehension, break out of...
more »

2017-05-21 16:05 (3) Answers

Intercepting JavaScript array accessor

I would like to associate some side effect with every array accessor like a[i]. For example, if the side effect is writing a message to the console, the following program: var array = [1, 2, 3] var total = 0; for (var i in array) { total +...
more »

2017-05-21 15:05 (2) Answers

error looping through a integer array in c

Alright so i have my array: unsiged int *arr = (unsigned int*)malloc(200 * sizeof(unsigned int)); Declared like this, and i have wrote a loop that loops through each element of the array and calls a function with the element as its argument, which ...
more »

2017-05-21 00:05 (2) Answers

PHP MVC Add to array on post

I have the below code and whenever I post a value it doesn't add it to the array. It is like it creates a new array with only the value I posted. <?php class Model { public $task; public function __construct() { $this->t...
more »

2017-05-20 22:05 (1) Answers

Getting indexes of maximum number in array

I have an array containing numbers which are ranks. Something like this. 0 4 2 0 1 0 4 2 0 4 0 2 Here 0 corresponds to the lowest rank and max number corresponds to highest rank. There may be multiple indexes containing Highest Rank. I want to fin...
more »

2017-05-20 11:05 (3) Answers

Array Search in C#

I am Trying search an array to find another smaller array Values. I used a nested loop and values found are displayed perfectly. but, I want also to print the values not found, can anyone help me improving my code so that value not found be printed i...
more »

2017-05-20 10:05 (6) Answers

How to nest unboxed vectors?

This may be a pretty basic question, but I've searched around and I cannot seem to find the answer. I would like to represent a 2D list using unboxed Vectors. This is easily done with normal vectors: > import qualified Data.Vector as V > V.fr...
more »

2017-05-20 08:05 (1) Answers

Doesn't prints the entire array properly

Here is my code for an atm machine. It first asks the user for card number then Pin and then expiry date. char card_number[16]; memset(card_number,0,16); char pin[4]; memset(pin,0,4); char exp_date[5]; memset(exp_date,0,5); printf("Enter Card numbe...
more »

2017-05-20 02:05 (3) Answers

What is the difference between any and any[ ]?

What is the difference between any and any[ ]? Example 1 (working as expected) name1: any; name2: any[]; this.name1 = this.name2; Example 2 (This is also working as expected) name2: any; name1: any[]; this.name1 = this.name2; Why type...
more »

2017-05-19 13:05 (2) Answers

Showing array value as the number in the array

Currently my code shows the year from 1885 to 2017. What this does is show the years like so 0 = 1885, 1 = 1886. What I want is that it shows it like this 1885 = 1885, 1886 = 1886 etc. (This resembles the date a car is built) $options = []; for ($...
more »

2017-05-19 10:05 (3) Answers

How to properly count occurrence in arrays?

I've got an in depth array (arrays of arrays). I'm trying to make a decent function without using any extra methods and JS designs (like closures). This is a working solution (but a bad one because of the global variable) var counter=0; functio...
more »

2017-05-18 18:05 (4) Answers

Union of arrays as aggregate function

I have the following input: name | count | options ----------------------- user1 | 3 | ['option1', 'option2'] user1 | 12 | ['option2', 'option3'] user2 | 2 | ['option1', 'option3'] user2 | 1 | [] I want the following output: name ...
more »

2017-05-18 14:05 (1) Answers

An array mapping function

I have this chunk of javascript code: function arrayMapper(mappingFunc) { return items => items.map(mappingFunc); } function fooTransformer(tem) { return (...); // do something with item and returns a value } function barTransformer(tem) { ...
more »

2017-05-17 18:05 (2) Answers

Putting values into an array and using array_sum

ok im a little stuck, i know its a simple thing im missing here so hoping fresh eyes will help I have values in a column stored as 2:7:99 etc each value is seperated by : Now I can seperate all the values out and query another table to get the pri...
more »

2017-05-17 14:05 (3) Answers