seq

How should I deal with 'from' must be of length 1 error?

我是研究僧i 提交于 2019-12-08 06:11:14
问题 I tried to count days between specific dates. I have 2 columns with all character vectors. start.date <- c("2015-01-10","2015-01-11","2015-02-24") end.date <- c("2015-03-10","2015-04-01","2015-06-13") date10 <- data.frame(cbind(start.date,end.date)) date10$start.date <- as.character(date10$start.date) date10$end.date <- as.character(date10$end.date) str(date10) and the specific dates are from 2015-04-11 to 2015-07-10. so I made all date which is between the specific dates by using seq(). sp

Differences between a seq and a list

主宰稳场 提交于 2019-12-07 02:32:28
问题 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. 回答1: First of all, they may seem to be the same, but they're not: (class (list [1 2 3])) => clojure.lang.PersistentList (class (seq [1 2 3])) => clojure.lang.PersistentVector$ChunkedSeq list is usually an implementation, whereas seq is always an abstraction. The differences between seqs and lists lies in the

F# PSeq.iter does not seem to be using all cores

时光毁灭记忆、已成空白 提交于 2019-12-06 19:16:26
问题 I've been doing some computationally intensive work in F#. Functions like Array.Parallel.map which use the .Net Task Parallel Library have sped up my code exponentially for a really quite minimal effort. However, due to memory concerns, I remade a section of my code so that it can be lazily evaluated inside a sequence expression (this means I have to store and pass less information). When it came time to evaluate I used: // processor and memory intensive task, results are not stored let

Create a time series by 30 minute intervals

二次信任 提交于 2019-12-06 04:08:54
I am trying to create a time series with 30 min intervals. I used the following command with the output also shown: ts = seq(as.POSIXct("2009-01-01 00:00"), as.POSIXct("2014-12-31 23:30"),by = "hour") "2010-02-21 12:00:00 EST" "2010-02-21 13:00:00 EST" "2010-02-21 14:00:00 EST" When I change it to by ="min" it changes to be every minute. How do I create a time series with every 30 minute intervals? You can specify minutes in the by argument, and pass the time zone "UTC" as Adrian pointed out. Check ?seq.POSIXt for more details about the by argument specified as a character string: A character

How in OS/X to get 'seq' command-line functionality?

老子叫甜甜 提交于 2019-12-06 02:42:49
I'm still on Snow Leopard (I know...) so forgive if this is fixed in one of the later versions of OS/X, but I want to do standard "seq" aka: for i in `seq 1 100` ; do cat /whatever > $i.txt ; done I thought installing GNU tools would do it, but apparently not. On my mac both of these work (OS X 10.8.5) Andreas-Wederbrands-MacBook-Pro:~ raven$ for i in {1..10}; do echo $i; done 1 2 3 4 5 6 7 8 9 10 Andreas-Wederbrands-MacBook-Pro:~ raven$ for i in `seq 1 10`; do echo $i; done 1 2 3 4 5 6 7 8 9 10 In Snow Leopard, you can use the jot command, which can produce sequential data like seq (and more,

Differences between a seq and a list

醉酒当歌 提交于 2019-12-05 06:06:16
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. albusshin First of all, they may seem to be the same, but they're not: (class (list [1 2 3])) => clojure.lang.PersistentList (class (seq [1 2 3])) => clojure.lang.PersistentVector$ChunkedSeq list is usually an implementation, whereas seq is always an abstraction. The differences between seqs and lists lies in the following three aspects, as pointed out in Clojure Programming 1. getting the length of a seq can be

Type inference in sequence expressions in F#

♀尐吖头ヾ 提交于 2019-12-05 02:47:56
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 following F# code we have a base class A and two derived classes, B and C: type A(x) = member a.X = x type B(x) = inherit A(x) type C(x) = inherit A(x) If I try to "yield" their instances in a simple sequence expressions, I get two errors: // Doesn't work, but it makes sense. let testSeq = seq { yield A(0) yield B(1) // Error, expected type: A yield C(2) // Error, expected type: A } That can make sense,

F# PSeq.iter does not seem to be using all cores

。_饼干妹妹 提交于 2019-12-05 00:45:17
I've been doing some computationally intensive work in F#. Functions like Array.Parallel.map which use the .Net Task Parallel Library have sped up my code exponentially for a really quite minimal effort. However, due to memory concerns, I remade a section of my code so that it can be lazily evaluated inside a sequence expression (this means I have to store and pass less information). When it came time to evaluate I used: // processor and memory intensive task, results are not stored let calculations : seq<Calculation> = seq { ...yield one thing at a time... } // extract results from

Time cost of Haskell `seq` operator

戏子无情 提交于 2019-12-04 17:36:35
问题 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 useful, but it means that x is guaranteed to be evaluated before y is considered. That's awfully nice of Haskell, but does it mean that in x `seq` f x the cost of evaluating x will be paid twice ("discard the result")? 回答1: The seq function will discard the value of x , but since the value has been evaluated, all

why is Seq.iter and Seq.map so much slower?

耗尽温柔 提交于 2019-12-04 00:14:38
问题 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 doNothing _ = () let incr x = x + 1 #time arr |> Array.iter doNothing // this takes 14ms arr |> Seq.iter doNothing // this takes 74ms lst |> List.iter doNothing // this takes 19ms lst |> Seq.iter doNothing // this takes 88ms arr |> Array.map incr // this takes 33ms arr |> Seq.map incr |> Seq.toArray //