seq Questions
4
Solved
var seq = Seq[String]()
seq = seq :+ "hello"
var set = Set[String]()
set += "hello"
what's the difference between Seq and Set?
1
Solved
2
Solved
I am new to shell scripting and I am trying a simple task of getting the length of a sequence of numbers generated using seq.
With the help of a related post here: How to find the array length in ...
1
Solved
So I've made some utility classes and implicit conversions for them. However, it works fine when converting from a Seq but not from a Set, although the code is the same, and those two traits seem r...
4
Solved
Every collection in clojure is said to be "sequable" but only list and cons are actually seqs:
user> (seq? {:a 1 :b 2})
false
user> (seq? [1 2 3])
false
All other seq functions first conv...
3
Solved
What's the differences between seqs and lists in Clojure language?
(list [1 2 3]) => ([1 2 3])
(seq [1 2 3]) => ([1 2 3])
These two forms seem to be evaluated as the same results.
2
Solved
Is there a more idiomatic way to change a nested sequence of sequences into a nested set of sets?
def toNestedSet[T](tsss: Seq[Seq[Seq[T]]]): Set[Set[Set[T]]] =
tsss.map(_.map(_.toSet).toSet).to...
2
Solved
I am new to haskell, and have just come to the lazy world proramming. I read that the seq function is very special because it forces to use a strict evaluation in order to be more efficient in some...
1
Solved
Whilst solving the 12th project euler problem I set about making an infinite sequence to get successive triangular numbers. My first attempt was:
let slowTriangularNumbers =
let rec triangularNu...
Trifoliate asked 27/12, 2013 at 18:18
2
Solved
Given this code snippet:
someFunction x = print x `seq` 1
main = do print (someFunction "test")
why doesn't the print x print test when the code is executed?
$./seq_test
1
If I replace it ...
4
Solved
Basically I want to generate a sequence, say:
n is 2, the sequence will be 112
n is 3, sequence is 112123
n is 5, sequence is 112123123412345
I did come up with a solution
n=5
seq=1
for (i in 2...
3
Solved
I'm trying to print the following pattern using printf and seq:
0000
0001
0002
0003
My problem is once I use:
seq 0 10 | xargs printf %04d
all my output is formatted into the same line likeso...
4
Solved
I'm using the Sesame library to run SPARQL queries over an in-memory triple store.
I am using Clojure to achieve this.
A query result is a custom Iterator-like [1] object, so the clojure seq does...
5
Solved
I think I do not quite understand how F# infers types in sequence expressions and why types are not correctly recognized even if I specify the type of the elements directly from "seq".
In the foll...
1
Solved
As shown in this answer, seq combined with undefined does very strange things when it comes to equational reasoning, for example it can make any monad fail. Another example is in this question.
Re...
Burnett asked 7/12, 2012 at 21:35
2
Solved
What are good examples of when seq_along will work, but seq will produce unintended results?
From the documentation of ?seq we have:
Note that it dispatches on the class of the first argument
...
2
Solved
I wrote a method that accepts objects of all subclasses of Seq[String]. Unfortunately it won't accept an object of the type Array[String]. Is Array[String] not a subclass of Seq[String]?
scala>...
Sudan asked 17/7, 2012 at 12:59
3
Solved
I am working in clojure with a java class which provides a retrieval API for a domain specific binary file holding a series of records.
The java class is initialized with a file and then provides...
Airline asked 10/7, 2012 at 13:9
1
The page Foldr Foldl Foldl' discusses foldl', and defines it like:
foldl' f z [] = z
foldl' f z (x:xs) = let z' = z `f` x
in seq z' $ foldl' f z' xs
This is done to avoid space leaks, i.e. so ...
Shingly asked 19/6, 2012 at 3:15
2
Solved
I'm new to Clojure and I was wondering if there's a way to create a sequence of maps from two or more sequences.
Let's say you have:
(def numbers '(1 2 3))
(def letters '("a" "b" "c"))
(def shape...
Oakie asked 10/6, 2012 at 8:0
1
Solved
Consider this code in F#:
let n = 10000000
let arr = Array.init n (fun _ -> 0)
let rec buildList n acc i = if i = n then acc else buildList n (0::acc) (i + 1)
let lst = buildList n [] 0
let d...
Snotty asked 3/6, 2012 at 22:47
2
Solved
Lets say I have the following:
f :: a -> b -> c
g :: b -> c
g = f 10
Now lets say f is actually:
f x y = f1 x + y
Would:
g `seq` ...
actually evaluate f1 10, so later when running...
5
Solved
This FAQ says that
The seq operator is
seq :: a -> b -> b
x seq y will evaluate x, enough to check that it is not bottom, then
discard the result and evaluate y. This might not seem ...
Aristotelianism asked 14/3, 2012 at 17:44
1
Solved
Say, I have a sequence of strings as an input and I want to get a new immutable Seq which consists of elements of the input and an item "c". Here are two methods that I've discovered to be working:...
2
Is there any concise way to convert a Seq into ArrayBuffer in Scala?
Dovev asked 26/9, 2011 at 9:40
© 2022 - 2024 — McMap. All rights reserved.