F#, char seq -> strings
I was just researching this myself. I found that System.String.Concat works pretty well, e.g. “abcdef01234567” |> Seq.take 5 |> String.Concat;; assuming that you’ve opened System.
I was just researching this myself. I found that System.String.Concat works pretty well, e.g. “abcdef01234567” |> Seq.take 5 |> String.Concat;; assuming that you’ve opened System.
For reference sake, if you do not have control over the generation of the numeric values, you can do padding with: % value=314 % echo ${(l:10::0:)value} 0000000314 % echo $value 314
Nothing. In the Seq doc, at the size method it is clearly stated: “The size of this sequence, equivalent to length.”.
JavaConverters is what I needed to solve this. import scala.collection.JavaConverters; public Seq<String> convertListToSeq(List<String> inputList) { return JavaConverters.asScalaIteratorConverter(inputList.iterator()).asScala().toSeq(); }
Use the :+ (append) operator to create a new Seq using: val seq = Seq(“a”, “b”) :+ “c” // seq is now (“a”,”b”,”c”) Note: :+ will create a new Seq object. If you have val mySeq = Seq(“a”,”b”) and you will call mySeq :+ “c” mySeq will still be (“a”,”b”) Note that some implementations of … Read more
In bash, brace expansion happens before variable expansion, so this is not directly possible. Instead, use an arithmetic for loop: start=1 end=10 for ((i=start; i<=end; i++)) do echo “i: $i” done OUTPUT i: 1 i: 2 i: 3 i: 4 i: 5 i: 6 i: 7 i: 8 i: 9 i: 10
Executing seq(1, 10, 1) does what 1:10 does. You can change the last parameter of seq, i.e. by, to be the step of whatever size you like. > #a vector of even numbers > seq(0, 10, by=2) # Explicitly specifying “by” only to increase readability > [1] 0 2 4 6 8 10
This should make the difference clear. Basically, seq() acts like seq_along() except when passed a vector of length 1, in which case it acts like seq_len(). If this ever once bites you, you’ll never use seq() again! a <- c(8, 9, 10) b <- c(9, 10) c <- 10 seq_along(a) # [1] 1 2 3 … Read more