Questions tagged [sequence]

A sequence is an ordered list of objects (or events). Like a set, it contains members (also called elements or terms), and the number of terms (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence. In a relational database, a sequence is an object that is used to generate unique numbers for a primary key.

A sequence is an ordered list of objects (or events). Like a set, it contains members (also called elements or terms), and the number of terms (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence.

Sometimes, sequence is used as a generic name for both list, array and set for convenience.

In a , a sequence is an object that is used to generate unique numbers for a .

5959 questions
28
votes
5 answers

Mapping PostgreSQL serial type with Hibernate annotations

I am using Hibernate 3.3 and PostgreSQL 8.x and would like to use Hibernate annotations to map an auto-incremented column which is NOT a primary key. It doesn't matter if the column is mapped using SERIAL type or sequences in Postgres as long as it…
alecswan
  • 499
  • 1
  • 6
  • 12
28
votes
4 answers

Add a range of items to the beginning of a list?

The method List.AddRange(IEnumerable) adds a collection of items to the end of the list: myList.AddRange(moreItems); // Adds moreItems to the end of myList What is the best way to add a collection of items (as some IEnumerable) to the…
Dave New
  • 38,496
  • 59
  • 215
  • 394
28
votes
4 answers

Idiomatic sequence slice in Clojure

In Python, there is a convenient way of taking parts of a list called "slicing": a = [1,2,3,4,5,6,7,8,9,10] # ≡ a = range(1,10) a[:3] # get first 3 elements a[3:] # get all elements except the first 3 a[:-3] # get all elements except the last…
Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166
28
votes
11 answers

Expand ranges defined by "from" and "to" columns

This problem is also known as 'transforming a "start-end" dataset to a panel dataset' I have a data frame containing "name" of U.S. Presidents, the years when they start and end in office, ("from" and "to" columns). Here is a sample: presidents <-…
edgester
  • 493
  • 4
  • 14
27
votes
1 answer

Skip first N elements in scala iterable

I'd like to know if scala includes a way to skip the first N elements of an iterable, so that for instance (1 to 5).WHATIWANT(3).foreach(println(_)) would print only 4 and 5. I understand there's slice, but if the length of the sequence can't be…
em70
  • 6,088
  • 6
  • 48
  • 80
27
votes
4 answers

Seq count number of elements

What is the easiest way to count the number of elements in a sequence in F#?
Mark Pearl
  • 7,573
  • 10
  • 47
  • 57
27
votes
5 answers

Splitting list based on missing numbers in a sequence

I am looking for the most pythonic way of splitting a list of numbers into smaller lists based on a number missing in the sequence. For example, if the initial list was: seq1 = [1, 2, 3, 4, 6, 7, 8, 9, 10] the function would yield: [[1, 2, 3, 4],…
billybandicoot
  • 273
  • 1
  • 3
  • 4
27
votes
3 answers

How can I make A future of future into one future object?

Env: Akka 2.1, scala version 2.10.M6, JDK 1.7,u5 Now is my problem: I have: future1 = Futures.future(new Callable>(){...}); future2 = ? extends Object; Future.sequence(future1, future2).onComplete(...) now in first line, I have a…
Vincent Zou
  • 431
  • 1
  • 5
  • 10
26
votes
7 answers

Type Int does not conform to protocol sequence

I have the following code in Swift 3: var numbers = [1,2,1] for number in numbers.count - 1 { // error if numbers[number] < numbers[number + 1] { print(number) } } I am checking if the value on the index [number] is always higher…
Toby V.
  • 425
  • 1
  • 6
  • 15
26
votes
10 answers

How to use existing Oracle sequence to generate id in hibernate?

I have legacy Oracle db with a sequence named PRODUCT_ID_SEQ. Here is the mapping of Product class for which I need generate correct ids: public class Product { @GeneratedValue(strategy = GenerationType.SEQUENCE, …
Vladimir
  • 12,753
  • 19
  • 62
  • 77
25
votes
4 answers

How to compute multiple sequence alignment for text strings

I'm writing a program which has to compute a multiple sequence alignment of a set of strings. I was thinking of doing this in Python, but I could use an external piece of software or another language if that's more practical. The data is not…
a3nm
  • 8,717
  • 6
  • 31
  • 39
25
votes
6 answers

Generate a sequence of numbers with repeated intervals

I am trying to create sequences of number of 6 cases, but with 144 cases intervals. Like this one for example c(1:6, 144:149, 288:293) 1 2 3 4 5 6 144 145 146 147 148 149 288 289 290 291 292 293 How could I generate automatically such…
giac
  • 4,261
  • 5
  • 30
  • 59
25
votes
3 answers

Create counter within consecutive runs of values

I wish to create a sequential number within each run of equal values, like a counter of occurrences, which restarts once the value in the current row is different from the previous row. Please find an example of input and expected output…
Richard
  • 1,224
  • 3
  • 16
  • 32
25
votes
3 answers

OEIS A002845: Number of distinct values taken by 2^2^...^2 (with n 2's and parentheses inserted in all possible ways)

I am looking for a reasonably fast algorithm to calculate terms of the OEIS sequence A002845. Let me restate its definition here. Let ^ denote the exponentiation operator. Consider expressions of the form 2^2^...^2 having n 2's with parentheses…
Vladimir Reshetnikov
  • 11,750
  • 4
  • 30
  • 51
24
votes
3 answers

Hibernate with Oracle sequence doesn't use it

I have configured hibernate to use oracle sequence. Sequence is created with cache=20, increment=1. All works fine, hibernate persisting entities. The id value is strange: 50,51....76,201,202...209,1008,1009,5129,5130 .... If I ask for sequence…
Vlada
  • 559
  • 2
  • 11
  • 27