Questions tagged [sequences]

A sequence is any type for which there is a bijective relation between the integers `0..n` and the elements of the sequence, and the elements may be accessed in the order `0..n`, where `n` is the number of elements in the sequence.

A sequence is any type for which there is a bijective relation between the integers 0..n and the elements of the sequence, and the elements may be accessed in the order 0..n, where n is the number of elements in the sequence.

A sequence may be infinite, in which case, the relation is with the open range 0....

538 questions
6
votes
2 answers

How should I implement an atomic sequence in Perl?

I have the following requirements: The sequence is unique to a host (no shared incrementing is necessary) The sequence must be monotonically increasing. The sequence must be persistent across processes. Incrementing the sequence must be atomic in…
Chris R
  • 17,546
  • 23
  • 105
  • 172
6
votes
2 answers

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…
rz.
  • 19,861
  • 10
  • 54
  • 47
6
votes
2 answers

What is the name of such diagrams?

I would like to generate diagrams similar to this, but I don't have a clue what to look for.
nowox
  • 25,978
  • 39
  • 143
  • 293
6
votes
1 answer

Create long data format based on strings of sequences defined by colons and concatenated vectors

I have data where the IDs of each observation are numbers stored as sequences usually in the form of X:Y, but sometimes concatenated lists. I would like to tidy the data so each observation has its own row so that I can then use a join function to…
G_T
  • 1,555
  • 1
  • 18
  • 34
6
votes
2 answers

How does Julia interpret 10:1?

I'm an expat from focusing on R for a long time where the : (colon) operator creates integer sequences from the first to the second argument: 1:10 # [1] 1 2 3 4 5 6 7 8 9 10 10:1 # [1] 10 9 8 7 6 5 4 3 2 1 Noticing that this…
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
6
votes
2 answers

Postgres 'if not exists' fails because the sequence exists

I have several counters in an application I am building, as am trying to get them to be dynamically created by the application as required. For a simplistic example, if someone types a word into a script it should return the number of times that…
Shadow
  • 8,749
  • 4
  • 47
  • 57
6
votes
4 answers

Repeating vectors in Clojure

I am a Clojure newbie. I am trying to get two copies of a vector of card suits. The non-DRY way that I can come up with is (def suits [:clubs :diamonds :hearts :spades]) (def two-times (concat suits suits)) There must be a more functional way (even…
Ralph
  • 31,584
  • 38
  • 145
  • 282
6
votes
6 answers

What's the alternate character combination for the double quote character in C/C++?

I've not had the Kernighan and Ritchie C reference in years, but I remember that there was a page in there that talked about how to enter characters that were unavailable to you. (WAY back in the day, some keyboards lacked characters like ", ~,…
Sniggerfardimungus
  • 11,583
  • 10
  • 52
  • 97
6
votes
3 answers

How to check if a sequence exists in my schema?

Is there a way to retrieve all the sequences defined in an existing oracle-sql db schema? Ideally I would like to use something like this: SELECT * FROM all_sequences WHERE owner = 'me'; which apparently doesn't work.
Christos
  • 846
  • 3
  • 15
  • 21
6
votes
1 answer

Reset A Sequence

I've read several posts about the TSQL Identity Bug and have been playing around with using SEQUENCE. However, I'm curious about resetting the SEQUENCE on the ID value in a table. For an example: CREATE SEQUENCE Inc AS INT START WITH 1 …
Question3CPO
  • 1,202
  • 4
  • 15
  • 29
6
votes
2 answers

Additive Sequence Algorithm

I am practicing algorithms for interviews and came across this question on Career Cup and SO An additive sequence number is which when splitted in two different number forms additive seq. Ex: 1235 (split it 1,2,3,5) Ex: 12122436(split…
Vbp
  • 1,912
  • 1
  • 22
  • 30
6
votes
2 answers

How to generate for loop number sequence by using variable names in bash?

Could anybody explain how can I use variable names in bash for loop to generate a sequence of numbers? for year in {1990..1997} do echo ${year} done Results: 1990 1991 1992 1993 1994 1995 1996 1997 However year_start=1990 year_end=1997 for year…
wiswit
  • 5,599
  • 7
  • 30
  • 32
6
votes
2 answers

Clojure sub-sequence position in sequence

Does Clojure provide any builtin way to find the position of a sub-sequence in a given sequence?
Tudor Vintilescu
  • 1,450
  • 2
  • 16
  • 28
6
votes
4 answers

Creating a sequence for a varchar2 field in Oracle

I want to create a sequence for this varchar. It would have been easier had it been a number instead of varchar. In that case, I could do seq_no := seq_no + 1; But what can I do when I want to store next value in column as A0000002, when the…
ykombinator
  • 2,724
  • 7
  • 25
  • 46
5
votes
2 answers

increasing decreasing sequence

A sequence in which the value of elements first decrease and then increase is called V- Sequence. In a valid V-Sequence there should be at least one element in the decreasing and at least one element in the increasing arm. For example, "5 3 1 9 17…