sequences

Where can I find the time and space complexity of the built-in sequence types in Python

I've been unable to find a source for this information, short of looking through the Python source code myself to determine how the objects work. Does anyone know where I could find this online? ...

C++ API for returning sequences in a generic way

If I am writing a library and I have a function that needs to return a sequence of values, I could do something like: std::vector<int> get_sequence(); However, this requires the library user to use the std::vector<> container rather than allowing them to use whatever container they want to use. In addition, it can add an extra copy o...

Manually inserting data in a table(s) with primary key populated with sequence

I have a number of tables that use the trigger/sequence column to simulate auto_increment on their primary keys which has worked great for some time. In order to speed the time necessary to perform regression testing against software that uses the db, I create control files using some sample data, and added running of these to the build...

How to update unique values in SQL using a PostgreSQL sequence?

In SQL, how do update a table, setting a column to a different value for each row? I want to update some rows in a PostgreSQL database, setting one column to a number from a sequence, where that column has a unique constraint. I hoped that I could just use: update person set unique_number = (select nextval('number_sequence') ); but i...

Spring + Hibernate: how to have a configurable PK generator?

We use Spring + Hibernate for a Webapp. This Webapp will be deployed on two unrelated production sites. These two production sites will use the Webapp to generate and use Person data in parallel. What I need to do, is to make sure that the Persons generated on these two unrelated production sites all have distinct PKs, so that we can m...

What's the best way to write [0..100] in C#?

I'm trying to think of clever, clear, and simple ways to write code that describes the sequence of integers in a given range. Here's an example: IEnumerable<int> EnumerateIntegerRange(int from, int to) { for (int i = from; i <= to; i++) { yield return i; } } ...

How would you implement sequences in Microsoft SQL Server?

Does anyone have a good way of implementing something like a sequence in SQL server? Sometimes you just don't want to use a GUID, besides the fact that they are ugly as heck. Maybe the sequence you want isn't numeric? Besides, inserting a row and then asking the DB what the number just seems so hackish. ...

Correct way to detect sequence parameter?

I want to write a function that accepts a parameter which can be either a sequence or a single value. The type of value is str, int, etc., but I don't want it to be restricted to a hardcoded list. In other words, I want to know if the parameter X is a sequence or something I have to convert to a sequence to avoid special-casing later. I...

How to use a Oracle function for the ID in Hibernate

Hi, Until recently we used Oracle sequences to generate the IDs of a table. This is now changed, a new ID is now calculated by an Oracle function. Which means that my application needs a change to adept to the new situation. The application is a Spring/Hibernate webApp, which access the Oracle database. This was configured in an hbm.xml...

Autoincrement in Oracle

What are the other ways of achieving autoincrement in oracle other than use of triggers? ...

Comprehension for flattening a sequence of sequences?

If I have sequence of sequences (maybe a list of tuples) I can use itertools.chain() to flatten it. But sometimes I feel like I would rather write it as a comprehension. I just can't figure out how to do it. Here's a very construed case: Let's say I want to swap the elements of every pair in a sequence. I use a string as a sequence here...

How are managed the sequences by JPA and Hibernate?

Hi all, I am using Hibernate in my project, and many of my entities use a sequence for their technical keys. For example: @Entity @Table(name = "T_MYENTITY") @SequenceGenerator(name = "S_MYENTITY", sequenceName = "S_MYENTITY") public class MyEntity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_MYENTI...

Why do you hate sequences on Oracle?

Some people don't like sequences on Oracle. Why? I think they are very easy to use and so nice. You can use them in select, inserts, update,... ...

How to write the Fibonacci Sequence in Python

Updated: EDIT! I have coded the program wrongly. Instead of returning the Fibonacci numbers between a range (ie. startNumber 1, endNumber 20 should = only those numbers between 1 & 20), I have written for the program to display all Fibonacci numbers between a range (ie. startNumber 1, endNumber 20 displays = First 20 Fibonacci numbers). ...

iPhone SDK: Record time of buttons in a sequence to play back

I've got an app in development where you press a button to play a sound using System beep. Instead of recording the output, I was thinking of recording the timing of when the buttons were pressed, so when the user presses a 'Play' button, the buttons are pressed in the same timing the user has pressed them, so it acts like the iPhone ha...

F# how to abstract Console.ReadLine() as string seq

Hi, I want to write a function to abstract Console.ReadLine() into a string seq the seq should break when line = null ConsoleLines(): unit -> string seq To be used like this: for line in ConsoleLines() do DoSomething line How do you write this function? Thanks ...

Can anyone provide a more pythonic way of generating the morris sequence?

I'm trying to generate the morris sequence in python. My current solution is below, but I feel like I just wrote c in python. Can anyone provide a more pythonic solution? def morris(x): a = ['1', '11'] yield a[0] yield a[1] while len(a) <= x: s = '' count = 1 al = a[-1] for i in range(0,le...

what causes an f# sequence to re-enumerate?

i have a parser that is effectively a set of recursive functions operating on a sequence of lexer tokens. The problem i'm running into is that the sequence seems to restart from the beginning on recursive function calls. Given the following skeleton definition for function Parse let restricted = Seq.take_while token_search tokens ...

Computing A Specific Generating Function Sequence

http://www.research.att.com/~njas/sequences/A097196 I was wondering how to continue generating the sequence given in the link. It is based off a generating function. Any ideas would be appreciated. Certain numbers in a certain sequence of this sequence are showing up as answers to subproblems of Project Euler problem 208 (robot walks...

How do I generate character sequences like hexadecimal with a different base?

I have the following Perl script that generates a string based on a number: my @chars; push @chars, map(chr, 48..57), map(chr, 97..122); my $c = $#chars+1; for (0..50) { my $string; my $l = $_ / $c; my $i = int $l; my $r = ($l - $i) * $c; $string .= $chars[$r]; while ($i > 0) { $l = $i / $c; $i =...