range

How to select random values from a given range.

I'm trying to create an android application which will generate random series of values (integer numbers in this case) in a given range (but NOT equal between them) and display them in a simple TextView Let's say we have the range R = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] Each time I press the button "Generate" I want to randomly...

Peoplecode- Range in Scroll area grid

I have a scroll area and grid. What I want is when the user clicked the save button and for example he/she is on the range of 21-30 rows, after the save button was clicked, the page will still remain on the 21-30 range. It's because my page go back from the starting range when I clicked the save button which is from 1-10. The cursor s...

How do I write a function that takes a range or list of arguments in Excel VBA?

With SUM for instance, I can do things like: =SUM(F5:F7,F6:F8,A1,E7:G7,F7,2,7) Which takes multiple ranges and/or individual cells and it adds them all up. My question is how do I do this with a VBA function, e.g. to generalize a binary XOR: Function BXOR(A As Integer, B As Integer) As Integer BXOR = CLng(A) Xor CLng(B) End Func...

how to set x-axis limits in ggplot2 R plots?

Say I plot the following in R: library(ggplot2) carrots <- data.frame(length = rnorm(500000, 10000, 10000)) cukes <- data.frame(length = rnorm(50000, 10000, 20000)) carrots$veg <- 'carrot' cukes$veg <- 'cuke' vegLengths <- rbind(carrots, cukes) ggplot(vegLengths, aes(length, fill = veg)) + geom_density(alpha = 0.2) Now say I only ...

how to iterate subranges in a "cyclic array"?

I'm trying to write the following perl subroutine. Given are an array a of length n, an index i in the array (0<=i<n an upstream window length u and a downstream window length d. I want to iterate over the values in the upstream window and the downstream window to i. In the simplest case, this will iterating over the values in a[i-u..i...

Why is the range of bytes -128 to 127 in Java?

OK, this is as noob as it gets, but I still don't get why the lowest value a byte can take is -128. That the highest value is 127 I can understand, because it's 01111111 in binary, but how does one represent -128 with only 8 bit, one of which is used for the sign? Positive 128 would already be 8-bit, i.e. 10000000, and then you need a 9t...

Merging overlapping ranges in PHP arrays?

I have an array in the following format: array( 0 => array(1, 5), 1 => array(4, 8), 2 => array(19, 24), 3 => array(6, 9), 4 => array(11, 17), ); Where each item is a X-to-Y range. What I would like to merge the overlapping ranges in the array, to get something more like this: array( 0 => array(1, 9), // 1-5, 4-8 and 6-9 a...

Javascript text range in firefox + greasemonkey

Hello, i m a beginner but i need a script that could help me in some pages. I need a script that analazizes the text in the page and if there is the word that i m searching for it shows a popoup, if not does nothing. here s the code but it doesn t work with firefox because the text range function is only for IE (probably won t work eithe...

How to alternate moveStart in Firefox?

Does anybody know how to use range.setStart in the same way as range.moveStart works in IE? I'd like to implement backspace/delete in JS, something like this: range.moveStart('character',-1); range.deleteContents(); but in Firefox ...

Python: Iterate a certain number of times without storing the iteration number anywhere

Hello... I was wondering if it is possible to perform a certain number of operations without storing the loop iteration number anywhere. For instance, let's say I want to print two "hello" messages on the console. Right now I know I can do: for i in range(2): print "hello" but then the "i" variable is going to take the values 0 ...

MySQL: Which indexes to use for a simple range select?

Hello, I have a table with ~30 million rows ( and growing! ) and currently i have some problems with a simple range select. The query, looks like this one: SELECT SUM( CEIL( dlvSize / 100 ) ) as numItems FROM log WHERE timeLogged BETWEEN 1000000 AND 2000000 AND user = 'example'</pre> It takes minutes to finish and i think that the s...

Array of indexes to array of ranges

Ranges in ruby are pretty cool. I end up with arrays such as this: geneRanges = [(234..25), (500..510), (1640..1653)] And subsequently have to remove bits of them. For that I: genePositions = geneRanges.collect {|range| range.entries }.flatten => [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 1640, 1641, 1642, 1643, 1644, ...

php range query

Hi, Basic question here. I am using php(smarty) range to populate an array for days in the month. $smarty->assign('date', range(1,31 )); The form sends OK, but because counts start at 0, when I pick 20 from dropdown 19 gets sent in the form. How do I set it so it starts at 1? ...

are F# ranges evaluated at compile time or run time

the (..) and (.. ..) operators in F# are unrolled at some point, is that a compile time operation or a run time operation? in either case, what are the performance of this? i.e. is it possible to build a custom function that does those operations faster? ...

Select range in contenteditable div

I've got a contenteditable div and a few paraprahs in it, as the code below. <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <div id="main" contenteditable="true" style="border:solid 1px black; width:300px; height:300px"><div>Hello world!</div><div><br></div><div>This is a...

Lucene Numeric range query doesn't return all of the hits I expect.

I have a set of documents that all have a "timestamp" field which is stored as a long integer number. The field is indexed in my Lucene index as a number using NumericField with a precision step of 8: NumericField("timestamp", 8). This is done so I can do numeric range queries to retrieve all documents that fall within a specific time ...

How can I efficiently count ranges that cover a given range in Perl?

I have a database of some 30k ranges, each is given as a pair of start and end points: [12,80],[34,60],[34,9000],[76,743],... I would like to write a Perl subroutine that a range (not from the database), and returns the number of ranges in the database which fully 'include' the given range. For example, if we had only those 4 ranges ...

ruby: Range is empty, but slicing with it produces elements?

I'm learning Ruby, and have just gotten into some stuff about arrays and ranges. I've run into something about slices that, while it makes sense at first glance, confuses me a bit when i look deeper into it. irb says that (2..-1).to_a is an empty array. Meaning no values in the range, right? But if i use that same range in [:a, :b, :c...

How to copy cell range as table from excel to powerpoint - VBA

I cant find any way to do this. What I have now is that it copy the range as an image: Dim XLApp As Excel.Application Dim PPSlide As Slide Set XLApp = GetObject(, "Excel.Application") XLApp.Range("A1:B17").Select XLApp.Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture PPSlide.Shapes.Paste.Select this works like a charm, b...

How to calculate that no sub range overlap each other and all sub range covers whole range in java?

I have a range in java implemented as a class which is divided into sub-ranges. The implementation is roughly as follows: public class Range { static public class Key implements Comparable<Key> { public int start; public int end; ... } Key range; SortedMap<Key, Range> subRange; } I want to make a func...