Questions tagged [alternating]

103 questions
14
votes
5 answers

Haskell - alternating elements from two lists

I'm trying to write a haskell function that takes in two lists of integers and generates a list with elements that have been taken alternatingly from the two lists. I have the function: blend xs ys An example: blend [1,2,3] [4,5,6] should…
Shabu
  • 645
  • 4
  • 11
  • 17
11
votes
1 answer

Knitr xtable row color result in 2nd table in the row header cell blacked out

Dear fellow R xtable and knitr users: I have been struggling with this problem for days now and I am very surprised there isn't a similar case reported by someone already. Your insight and help are greatly appreciated. I used xtable to make two or…
Jian Wang
  • 127
  • 8
5
votes
2 answers

Merge two flat indexed arrays of equal size so that values are pushed into the result in an alternating fashion

Suppose I have two arrays: $a1 = array(0, 1, 2); $a2 = array(3, 4, 5); I want to be able to do a merge technique that alternates the array values and not just concatenate them. I want this result: array(0, 3, 1, 4, 2, 5); Is there a native way to…
qwertymk
  • 34,200
  • 28
  • 121
  • 184
3
votes
5 answers

Alternating color rows in PHP loop

How can I have an alternating color rows in my php loop? $num = mysql_num_rows($qPhysician); $i=0; while($i < $num) { echo ""; echo "" . mysql_result($qPhysician,$i,"lastName") . ""; echo "" .…
3
votes
2 answers

How set css to alternating rows in angular 4

I would like to define a class to alternating rows in angular 4, how to do this? HTML
{{path.xyz}}
free
  • 153
  • 1
  • 2
  • 18
3
votes
1 answer

Alternate, interweave or interlace two matrices

I've got two matrices which I want to interweave/interlace/stack alternatively on top of each other/rbind in an alternating manner. ranks=1:3 names=c("Karl", "Klaus", "Mary") x <- cbind(ranks, names) universities=c("Cape Town", "London",…
MERose
  • 4,048
  • 7
  • 53
  • 79
3
votes
2 answers

Merge two LinkedList without creating a new LinkedList

I am trying to take the two linkedlist that I have in my executable file and merge them into each other in alternating positions. Ex. ListOne 1,2,3 and ListTwo 4,5 the new ListOne should be 1,4,2,5,3. LinkedList .h file: class…
Cameron
  • 185
  • 2
  • 11
2
votes
1 answer

How to alternate capitalizations with RegEX?

I need to change a sentence to have alternating capitalizations! Having trouble making it ignore the spacebar inputs... input: the quick brown fox jumps over the lazy dog output: tHe QuIcK bRoWn FoX jUmPs OvEr ThE lAzY dOg I tried the…
Baldur
  • 21
  • 1
2
votes
1 answer

Matlab unit tests alternate between pass and fail (pass "odd" runs, fail on "even")

I have some unit tests for code that is doing some very minor image manipulation (combining several small images into a larger image). When I was running the tests, I noticed that three out of four of them failed on the line where they are reading…
asdf
  • 109
  • 7
2
votes
1 answer

merge streams to produce alternating sequence using lambda or Stream API

I have some code which returns a Stream as intended, but maybe it can be replaced with some type of lambda or stream() operation instead of exhausting the iterators in a while loop? It is just a method that alternates elements from the streams first…
Serhii
  • 165
  • 1
  • 1
  • 8
2
votes
2 answers

Overflow from div to full width of screen with alternating background color

I am using the modified snippet below from another thread to create a max-width layout, but I'd like to change .flex-parent:after {yellow} to an alternating background color using pseudo selectors as shown by my attempt in SASS below. Can I do this…
Wren
  • 23
  • 2
2
votes
2 answers

alternating players and adding user inputs

I came across this java question and I wanted to see how easy it would be to write the code for it. Write a Java program that enables two people to play the following game. We start with a pile of chips. Your game will allow for numbers that are…
droidnoob
  • 333
  • 5
  • 17
2
votes
1 answer

Gson: fields that sometimes are strings and others arrays

I'm parsing json with Gson but I'm struggling with the data I'm getting. This is part of an API out of my control (openFDA) so changing that might not be an option. Here's the json I'm strugling with:…
javydreamercsw
  • 5,363
  • 13
  • 61
  • 106
2
votes
1 answer

Alternating row color for Listbox using MahApps.Metro

I'm trying to create an alternating row color for my listbox in WPF while using the MahApps.Metro project. When I add the style and triggers, the background of all items is still white: