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
4
votes
2 answers

Interpreting results of sequence mining with SPADE

Please help to interpret the results of SPADE frequent sequence mining algorithm (http://www.inside-r.org/packages/cran/arulesSequences/docs/cspade​) With support = 0.05: s1 <- cspade(x, parameter = list(support = 0.05), control = list(verbose =…
zork
  • 2,085
  • 6
  • 32
  • 48
4
votes
5 answers

Functional clustering of array values in Swift

Given an array, like: [0, 0.5, 0.51, 1.0, 1.5, 1.99, 2.0, 2.1, 2.5, 3.0] I want to cluster together values into subarrays based on their sequential differences (e.g., where abs(x-y) < n, and n = 0.2), e.g.: [[0], [0.5, 0.51], [1.0], [1.5], [1.99,…
jbm
  • 1,248
  • 10
  • 22
4
votes
7 answers

How can I determine the actual database row insertion order?

I have a multithreaded process which inserts several records into a single table. The inserts are performed in a stored procedure, with the sequence being generated INTO a variable, and that variable is later used inside of an INSERT. Given that…
aw crud
  • 8,791
  • 19
  • 71
  • 115
4
votes
1 answer

Given a set of non-negative integer tuples, can some preprocessing make it fast to tell if some tuple in the set dominates a given query tuple?

So this is motivated by a recent question, which asked how to quickly determine if a query word could be permuted to match a particular word in a given dictionary of words. The basic idea for a quick query solution was simple: First, for…
user2566092
  • 4,631
  • 15
  • 20
4
votes
5 answers

Trying to generate all sequences of specified numbers up to a max sum

Given the following list of descending unique numbers (3,2,1) I wish to generate all the sequences consisting of those numbers up to a maximum sum. Let's say that the sum should be below 10. Then the sequences I'm after are: 3 3 3 3 3 2 1 3 3 2 3 3…
Stécy
  • 11,951
  • 16
  • 64
  • 89
4
votes
3 answers

Split array by consecutive sequences

Given an array of integer such as: array = [1,2,3,5,6,7,20,21,33,87,88,89,101] This array contains k consecutive subsequences (in this case k = 6), such as "1,2,3" and "87,88,89". How do I get an array containing arrays of these k subsequences?…
user1297102
  • 661
  • 8
  • 14
4
votes
1 answer

How do I get a sequence's MINVALUE in Oracle 10g PL/SQL?

I wrote a PL/SQL script to set a sequence's value to the maximum value of a table's primary key: DECLARE max_idn NUMERIC(18, 0); seq_nextval NUMERIC(18, 0); increment_amount NUMERIC(18, 0); BEGIN SELECT MAX(mbr_idn) INTO max_idn FROM…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
4
votes
2 answers

Filtering when an infinite list begins to repeat

I am creating a sequence as a [Integer] in Haskell. The mathematical definition of the sequence is such that it repeats for some positive integers. In such a situation, I want to terminate the sequence and determine the length of the finite list. My…
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
4
votes
4 answers

Performance of F# code terrible

This is my very first F# programme. I thought I would implement Conway's Game of Life as a first exercise. Please help me understand why the following code has such terrible performance. let GetNeighbours (p : int, w : int, h : int) : seq = …
Shredderroy
  • 2,860
  • 2
  • 29
  • 53
4
votes
4 answers

Interesting strings algorithm

Given two finite sequences of string, A and B, of length n each, for example: A1: "kk", A2: "ka", A3: "kkk", A4: "a" B1: "ka", B2: "kakk", B3: "ak", B4: "k" Give a finite sequences of indexes so that their concentration for A and B gives the…
ooboo
  • 16,259
  • 13
  • 37
  • 32
4
votes
5 answers

Regex and a sequences of patterns?

Is there a way to match a pattern (e\d\d) several times, capturing each one into a group? For example, given the string.. blah.s01e24e25 ..I wish to get four groups: 1 -> blah 2 -> 01 3 -> 24 4 -> 25 The obvious regex to use is (in Python…
dbr
  • 165,801
  • 69
  • 278
  • 343
4
votes
2 answers

Obtaining elements at n to n+x in a sequence in fsharp

Quite simply, given a sequence in F#, how does one obtain elements from index n to index n+x (inclusive)? So, if I have a sequence like: {0; 1; 2; 3; 4; 5}, how to I get the sub-sequence from index 2 to 4? It would look like {2; 3; 4} Any answer…
MirroredFate
  • 12,396
  • 14
  • 68
  • 100
3
votes
5 answers

Recursively generate ordered substrings from an ordered sequence of chars?

Edited after getting answers Some excellent answers here. I like Josh's because it is so clever and uses C++. However I decided to accept Dave's answer because of it's simplicity and recursion. I tested them both and they both produced identical…
PowerApp101
  • 1,798
  • 1
  • 18
  • 25
3
votes
2 answers

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)…
tbjers
  • 564
  • 3
  • 13
3
votes
3 answers

Swapping every pair of items in an F# list

I'm positive that there is a better way to swap items in a list by pairs ( [1;2;3;4] -> [2;1;4;3] ) as I'm doing too many appends for my liking but I'm not sure how best to do it. let swapItems lst = let f acc item = match acc with …
Dylan
  • 1,306
  • 1
  • 11
  • 29