seq Questions
1
Solved
2
Solved
I have this code in F# which finds the smallest positive number that is evenly divisible by all of the numbers from 1 to 20. It takes 10 seconds to complete.
let isDivisableByAll num (divisors: in...
Echoism asked 20/6, 2016 at 9:16
1
Solved
I'm currently working on an F# library with GUI written in C# and I would like to ask what is the best or correct way to pass an F# (generic) list to a C# code (generic IEnumerable).
I've found th...
4
Solved
I'm an R newbie and probably the solution for my problem is very simple but it's out of my reach for now...
I would like to compare rows in a data frame by columns. The data in each column is a let...
4
I need get this:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,] 1 0 2 0 3 0 4 0 5
[2,] 0 0 0 0 0 0 0 0 0
[3,] 6 0 7 0 8 0 9 0 10
[4,] 0 0 0 0 0 0 0 0 0
[5,] 11 0 12 0 13 0 14 0 15
[6,] 0 0 0 0...
5
Solved
I define the following diff function on Seq[Int] which uses view to avoid copying data:
object viewDiff {
def main(args: Array[String]){
val values = 1 to 10
println("diff="+diffInt(va...
1
Solved
Which elements in F# are lazy evaluated, which elements are eager evaluated?
So far as I know, if "seq" is lazy evaluated, does it mean "list" is eager evaluated?
How I prove it? Thanks
Negress asked 25/2, 2016 at 9:19
2
We know that in F#, seq is lazy evaluated. My question is, if I have a seq with limited number of values, how to convert it into some data type that contains all its value evaluated?
> seq { fo...
Arbitress asked 3/2, 2016 at 5:37
3
Solved
I need to add an item to a Seq depending on a condition.
The only thing I have been able to do is:
if(condition){
part1 ++ part2 ++ Seq(newItem)
}
else {
part1 ++ part2
}
part1 and part2 are ...
Metagenesis asked 8/1, 2016 at 19:33
2
Solved
It works with a for loop and mutable variable:
let addLnNum filename =
use outFile = new StreamWriter(@"out.txt")
let mutable count = 1
for line in File.ReadLines(filename) do
let newLine = ...
1
Solved
I would like to create a simple for bash loop that iterates over a sequence of numbers with a specific interval and then a different sequence of numbers, e.g.
for i in $(seq 0 5 15)
do
echo $i
d...
2
Solved
Bash allows me to write the statement,
$ for i in {h..k} ; do echo $i ; done
but zsh only allows number list expansion such as {8..13}.
What's the best workaround? Something like seq for charac...
Villainy asked 7/3, 2010 at 1:5
1
Solved
I have a dataset that looks like this:
ID created_at
MUM-0001 2014-04-16
MUM-0002 2014-01-14
MUM-0003 2014-04-17
MUM-0004 2014-04-12
MUM-0005 2014-04-18
MUM-0006 2014-04-17
I am trying to intro...
1
Solved
What is the Nim equivalence of List.Clear in languages like java or c# for sequences? I see listed in system the proc setLen, but im not sure it does what i want. From the description:
f the curre...
3
Solved
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, bu...
4
Solved
Is there an alternative for F# "seq" construct in Erlang? For example, in F# I can write an O(1) memory integrate function
let integrate x1 x2 dx f =
let N = int (abs (x2-x1)/dx)
let sum = seq {...
1
Solved
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
Solved
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 ti...
2
Solved
At SO, I have seen questions that compare Array with Seq, List with Seq and Vector with well, everything. I do not understand one thing though. When should I actually use a Seq over any of these? I...
Externalism asked 22/1, 2015 at 15:15
1
Solved
I have a sequence of data which I need to filter. This is quite obvious as we have the Seq.filter value. But, my problem is that I need to filter until the resulting collection will reach certain n...
Unconcern asked 2/12, 2014 at 8:41
3
Solved
I'm currently generating a sequence in a similar way to:
migrators
|> Seq.map (fun m -> m())
The migrator function is ultimately returning a discriminated union like:
type MigratorResult ...
Newhouse asked 12/11, 2014 at 15:21
1
Solved
Here's a beginner's question: Is there a way in Clojure to lazily concatenate an arbitrary number of sequences? I know there's lazy-cat macro, but I can't think of its correct application for an ar...
Canikin asked 27/10, 2014 at 17:51
2
Solved
In the Scala documentation, collections have both .seq and a .toSeq method defined on them. What is the difference between them, and why are they both there? I wasn't able to figure it out from rea...
Mantegna asked 10/10, 2014 at 18:17
3
Solved
Let's say I had a vector:
remove <- c(17, 18, 19, 20, 24, 25, 30, 31, 44, 45).
How do I select / extract every second value in the vector? Like so: 17, 19, 24, 30, 44
I'm trying to use the se...
3
There is a well known solution for generating an infinite stream of Hamming numbers (i.e. all positive integers n where n = 2^i * 3^j * 5^k). I have implemented this in two different ways in F#. Th...
Bouffant asked 6/7, 2014 at 20:32
© 2022 - 2024 — McMap. All rights reserved.