I tried to use Map.map to convert a map into a List of Tuples. However this fails. I did the following experiments: val m = Map(("a" -> 1), ("b" -> 2)) //> m : scala.collection.immutable.Map[String,Int] = Map(a -> 1, b -> 2) val r1 = m.map{ case (k,v) => v}...

I'd like to generate a sequence of equally spaced decimal numbers. For example, I want to echo all numbers between 3.0 and 4.5, with step 0.1. I tried $ for i {3.0..4.5..0.1}; do echo $i; done, but this gives an error. I also tried $ for i in $(seq 3.0...

I am trying to subset one FASTA file (containing multiple sequences) into several smaller ones based on IDs I stored in a list of data frames (and I have a FASTA called fastafile like this: fastafile <- dput(fastafile) structure(list(r1 = "acatattggaggccgaaacaatgaggcgtgatcaactcagtatatcac", r2 = "ctaacctctcccagtgtggaacctctatctcatgagaaagctgggatgag", r3 = "atttcctcctgctgcccgggaggtaacaccctggacccctggagtctgca", r4 = "acatattggaggccgaaacaatgaggcgtgatcaactcagtatatcgg",...

Lets suppose I have a vector of numeric values [1] 2844 4936 4936 4972 5078 6684 6689 7264 7264 7880 8133 9018 9968 9968 10247 [16] 11267 11508 11541 11607 11717 12349 12349 12364 12651 13025 13086 13257 13427 13427 13442 [31] 13442 13442 13442 14142 14341 14429 14429 14429...

I'm really struggling to design an algorithm to find d, which is the lowest value that can be added or subtracted (at most) to make a given sequence strictly increasing. For example.. say seq[] = [2,4,8,3,1,12] given that sequence, the algorithm should return "5" as d because you can add...

I'm having a discussion about the use of seq for small loop in a Bash script (for example a loop with 10 iterations). I say, for example, is better do this for i in {1..10} do echo "Welcome $i times" done than use seq for i in $(seq 10) do...

It can be complicated problem but I will try to explain it as much as I could. I have a sequenced dataset containing number of observations which should be processed before plotting. I want do it with a function. because I have another datasets in the directory (around 20) #reproducible...

Given an var x: Array[Seq[Any]], what would be the most efficient (fast, in-place if possible?) way to remove the first element from each row? I've tried the following but it didn't work - probably because of immutability... for (row <- x.indices) x(row).drop(1) ...

Scala comes with the nice corresponds method: val a = scala.io.Source.fromFile("fileA").getLines().toSeq() val b = scala.io.Source.fromFile("fileB").getLines().toSeq() val areEqual = a.corresponds(b){_.equals(_)} if(areEqual) ... And I quite like the brevity of that. Is there a similar method already defined that will also report to me the first position in which the two sequences...

Here is duration data by time intervals. id <- c("A", "B", "B", "B", "C", "C", "D", "E", "F", "F", "F", "F") start <- c(368, 200, 230, 788, 230, 521, 272, 306, 0, 162, 337, 479) end <- c(373.98, 229.98, 233.98, 842.98, 239.98, 639.98, 285.98, 306.98, 95.98, 162.98, 339.98, 539.98) value...

This question already has an answer here: Why are these numbers not equal? 3 answers Can someone please help me understand why -1 + 1 <> 0 ? Can someone please help me understand why I get three different values between the built-in function consum(), my function ct(), and...

I have a data.frame which I want to generate random numbers each list by a sequence. I used sample function to create random numbers but even I created random numbers for list [[1]], for set [[2]] same numbers produced again. So, here how can I create different random numbers for...

Starting with number 1, how to add this number in front of the direct following next x lines, followed by number 2 also for the following next x lines, and so on, end must be by y lines, how to do that? 1 jeriro ieieie ieiue 1 ieirirp wzwezeg 1...

While debugging a memoization function I found myself trying to find out whether Seq.mapi was actually iterating over a sequence, so I replaced an anonymous function with a printfn call like so: let x = "test" |> Seq.map (fun c -> c |> printfn "%c") Quite to my surprise, the...

I have a table as below product=c("a","b","c") min=c(1,5,3) max=c(1,7,7) dd=data.frame(product,min,max) > dd product min max 1 a 1 1 2 b 5 7 3 c 3 7 I want to create a table which will look like below. I want to create one row for each value between and including...

I have this example data by<-200 to<-seq(from=by,to=35280,by=by) Problem is that to ends at 35200 and ignore the last 80 which I need to involve in as last value. Is there any straigthforward way how to achieve it? I have tried along.with and length.out parameters but I cannot go trough....

I have a df like ProjectID Dist 1 x 1 y 2 z 2 x 2 h 3 k .... .... I want to add a third column such that we have an incrementing counter for each ProjectID: ProjectID Dist counter 1 x 1 1 y 2 2 z 1...

I would try to perform a SQL JOIN like on results from MongoDB. I have data to show on grid: seqgroup: ({:_id #<ObjectId 54db3ba76a5b2d5de2e7e990>, :group_name gr1, :usersingroup_id [#<ObjectId 54d1e37a2039b30a00b342ca> #<ObjectId 54d8ab240e81f5d1cbf6f691>]} {:_id #<ObjectId 54db46ba6a5b2d5de2e7e992>, :group_name gr2, :usersingroup_id [#<ObjectId 54d8af860e81f5d1cbf71da3> #<ObjectId 54d8ab240e81f5d1cbf6f691>]}) Instead of ObjectId for :usersingroup_id I would like to...