arrays

  1. R

    How many times does array appear in another array?

    I'm new to Ruby on Rails. This question seems to be answered in other programming languages but not RoR. I have an array with 3 items in it. array1 = [1, 2, 3] I then have items in another array which i want to check and see how many times array1 appear in array2: array2 = [1, 2, 3, 4, 5, 6...
  2. I

    Cannot return array to main method

    Im trying to return intArray from the wordCheck method and the error cannot find symbol - variable intArray is appearing in lines 10,11, and 12 when I try to print the values from the array. I was wondering if I am declaring the method wrong or not using a proper return, or am possibly making my...
  3. J

    How to modify/split invidual string in an array

    How to create a method send in an array of names in “firstName lastName” form(ex:Anna Hale). The method returns the name(through a return statement) in the form “first---last”. Below is my full name array public static void readData(String file) throws FileNotFoundException { x = new...
  4. C

    Replace array value to increment

    I have an array like this ... [0,0,23,0,0,18,0,0] Then I want to change values that are not '0' (23 & 18) to auto increment, so the end result will be like this, [0,0,1,0,0,2,0,0] is there the best way for all that? So far this is what I did, but the results were not as expected ... :)...
  5. B

    How to retrieve values from a multi-d array in PHP?

    Here is an array from an user generated course-creation system. What would be the best way to retrieve values associated with [titreSection], [lessonTitle] and [lessonContent] keys ? Main goal here is to allow the user to create sections that contains a title with several lessons and content...
  6. N

    How to display php array

    This code will print result like this: test1@bnas.com.mytest2@bnas.com.my So how can I separate the result in 2 variable like email[0],email[1]??? $TEST='i192a'; $stid = oci_parse($conn, 'select email from BNS_NOTIFY_RECIPIENT where screen =:num0'); oci_bind_by_name($stid...
  7. M

    How to use a string as an object with diferent parameters in javascript?

    I have an array of post that is call test and the next code takes other array and push the post if the name equals something: var test = []; docs = [{name: 'mateo',lastName: 'mateo'}, {name: 'Jhon',lastName: 'smith'}}] docs.forEach(function(item) { if(item.name === 'mateo'){...
  8. E

    Given a hash of arrays, how to create an array of hashes with each possible combo

    Given a hash with values containing arrays of unequal lengths, {a: [1, 2, 3], b: [1, 2], c: [1]} is it possible to create an array of hashes containing the same keys, of all permutations of single values like the following without resorting to nesting multiple loops? [ {a: 1, b: 1, c: 1}...
  9. R

    Increase integer values within a integer array

    I have question regarding increase the values within a one dimensional integer array. For example an array like [0,0,0,0] and I want to increase the farthest right position in the array by one so [0,0,0,1]. I want to keep increase this value to a set limit for example [0,0,0,3] and once it...
  10. S

    SUM value in array PHP

    I have a problem with array. I want to sum up the given quantities (qty). I want to get: blyszczaca Normal = 6; czapkoszal Normal = 6; czapkoszal Luxury = 2; etola Wolf = 1; etola Normal = 2; from this array. Can you help me please? I think about it for the last 4 hours and nothing. Still...
  11. P

    Removing parts of a multidimensional array in PHP

    I have this array $data : Array ( [0] => 86086 [1] => Arnel [2] => Paras ) Array ( [0] => 86085 [1] => Arnely [2] => Para ) Array ( [0] => ) How do i remove the bottom array that contains no values totally so it only contains : Array ( [0] => 86086 [1] =>...
  12. D

    How to append values to an array in Bash by adding one element to the previous entry?

    I have a list of numbers 1 2 3 4 5 that I am trying to organize into an array where the values are in a sequence where the current value is the summation of the previous values in the array (like this): 1 3 6 10 15. My current code is as follows: array=() for n in `seq 1 5` do if [ $n -eq 1...
  13. K

    Calculating Median of an array in PHP

    I'm trying to figure out how to calculate the median of an array of randomly generated numbers. I have the array all set up, but I'm having trouble putting together a function for the calcuation. This is what I have so far: //array $lessFifty = array(); $moreFifty = array(); //number generation...
  14. M

    How to separate json object array received from php?

    I need to separate the 3 php objects arrays after json receiving them. Php code: $row = array(array($directionsStart),array($directionsEnd),$directionsWaypointArray); echo json_encode($row); the output of php: [["Belo Horizonte, Minas Gerais"],["Maric\u00e1, Rio de Janeiro"],["Monte Mor...
  15. L

    How to implement mixture of Strings and SpannableStrings in ArrayList without loads of additional code

    Is it possible to have a mixture of both String and SpannableString in an ArrayList without adding loads of code? public class MyFragment extends android.support.v4.app.Fragment { public MyFragment() {} @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup...
  16. B

    Evaluating array content (PHP, XenForo)

    I'm having few troubles when evaluating an array data to filter some content. I'm sending to the template an array with few numbers (1,4,5,10,12,14,20 - for example) and then i want to filter if it has a specific value. Let's say i want to know if it has '2' as a single value. What would be the...
  17. J

    Unexpected Results When Using Pointers to Access Array Elements

    I have two classes. class1 and class2. class2 creates an array with elements that are of type class1. class2 has a member that points to that array. I can access the pointer with class 2's getpointer method, but I get unexpected results when I try to use the pointer to access members of the...
  18. U

    Assigning a string variable to an unsigned char variable

    Assume I have a string s that represents a hex value: string s="0x80"; I want to assign the value of s to v, where v is defined as: unsigned char v; What is the simplest way of doing it? Why do I need it? Because in here, a bloom filter is represented as a vector of unsigned char where each...
  19. K

    Converting boost::filesystem::path into char ??

    i have worked out how to pass the boost path the required format, but i am having some issues figuring out hot to pass the path.stem into a char array, and then run some check on the filename and take the right action need to read the filename and check for the next available number in the and...
  20. A

    In C++ how can I extract members from an array and return an array of the member's type? [on hold]

    namespace detail { template <typename T, typename U> Array<U> extract_(const Array<T>& array, std::function<U(const T&)> member) { Array<U> extracted; for (auto& item : array) extracted += member(item); return extracted; } } #define...
Top