take

How to get total results count before .Take() - but when using .Take()

倾然丶 夕夏残阳落幕 提交于 2019-12-13 13:34:42
问题 I am using .Take() to get a fixed number of results. What is the best way to get the TotalCountBeforeTake (ie as if I didn't use the .Take())? Can I get the TotalCountBeforeTake without running the query twice? var Results = (from results in db.FindWords(term) orderby results.word select results.word).Take(100); //just to get the total record count int TotalCountBeforeTake = (from results in db.FindWords(term) select results.word).Count(); // only showing 100 out of TotalCountBeforeTake

F# take items from a sequence

≯℡__Kan透↙ 提交于 2019-12-11 13:00:42
问题 Im trying to learn F# What I would like to do is download a webpage, split it into a sequence then find the index of an item and take the next 3 items after it. Heres the code -- can someone show me what Im doing wrong please? let find = "<head>" let page = downloadUrl("http://www.stackoverflow.com") let lines = seq ( page.Replace("\r", System.String.Empty).Split([|"\n"|], StringSplitOptions.RemoveEmptyEntries) ) let pos = lines |> Seq.findIndex(fun a -> a == find) // getting a Exception of

how to `.Take()` on a string and get a string at the end?

邮差的信 提交于 2019-12-10 12:28:24
问题 LINQ to Objects supports queries on string objects but when I use code such as below: string SomeText = "this is some text in a string"; return SomeText.Take(6).ToString(); All I get is: System.Linq.Enumerable+<TakeIterator>d__3a`1[System.Char] This is discussed as an "accident" in this question but this is what I am actually trying to do and I cannot find it through search anywhere. I know there are other ways to manipulate strings but then I also know you can do some really cool tricks with

cassandra snapshot without nodetool but by java api only

无人久伴 提交于 2019-12-01 20:55:24
How to take cassandra snapshot without nodetool but by java api only? I need to take snapshot of keyspace in cassandra by not using nodetool utility. I have to do it by java api If any one know how to do it kindly answer it . I have to implement.. You can't take a snapshot using the thrift API, but you can take a snapshot using JMX, which is how the nodetool command works. Look at the node tool source here , in particular look at the handleSnapshot method. 来源: https://stackoverflow.com/questions/12403292/cassandra-snapshot-without-nodetool-but-by-java-api-only

Is 2-dimensional numpy.take fast?

自闭症网瘾萝莉.ら 提交于 2019-12-01 13:20:39
numpy.take can be applied in 2 dimensions with np.take(np.take(T,ix,axis=0), iy,axis=1 ) I tested the stencil of the discret 2-dimensional Laplacian ΔT = T[ix-1,iy] + T[ix+1, iy] + T[ix,iy-1] + T[ix,iy+1] - 4 * T[ix,iy] with 2 take-schemes and the usual numpy.array scheme. The functions p and q are introduced for a leaner code writing and adress the axis 0 and 1 in different order. This is the code: nx = 300; ny= 300 T = np.arange(nx*ny).reshape(nx, ny) ix = np.linspace(1,nx-2,nx-2,dtype=int) iy = np.linspace(1,ny-2,ny-2,dtype=int) #------------------------------------------------------------

Issues taking picture with Android (Vertical Camera | Portrait)

六月ゝ 毕业季﹏ 提交于 2019-11-30 22:40:05
With the following code shows a preview of the camera vertically and it's works.. BUT!! I get a photo in landscape! :( How I can build it vertically? I've the preview view in vertical, but I can't save the picture vertically. greetings and thanks, Fran ONCLICK public void onClick(View arg0) { camera.takePicture(myShutterCallback, myPictureCallback_RAW, myPictureCallback_JPG); } PREVIEW @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { if (previewing) { camera.stopPreview(); previewing = false; } if (camera != null) { /* * camera.setPreviewDisplay

How can I write Take(1) in query syntax

孤者浪人 提交于 2019-11-30 07:54:37
问题 Is it possible to write IQueryable<MyObject> = query.Take(1) or something equivalent in LINQ query syntax. I'm using C# 5 and EF 5. 回答1: There is no equivalent to Take in the query expression syntax for LINQ in C#. The only methods that have query expression equivalents are Where, Select, SelectMany, Join, GroupJoin, OrderBy, OrderByDescending, ThenBy, ThenByDescending, GroupBy, Cast This is from §7.16.2 of the specification. 回答2: No. You have to use the dot syntax for that operation. Same

RxJava2 observable take throws UndeliverableException

放肆的年华 提交于 2019-11-28 17:13:27
As I understand RxJava2 values.take(1) creates another Observable that contains only one element from the original Observable. Which MUST NOT throw an exception as it is filtered out by the effect of take(1) as it's happened second. as in the following code snippet Observable<Integer> values = Observable.create(o -> { o.onNext(1); o.onError(new Exception("Oops")); }); values.take(1) .subscribe( System.out::println, e -> System.out.println("Error: " + e.getMessage()), () -> System.out.println("Completed") ); Output 1 Completed io.reactivex.exceptions.UndeliverableException: java.lang.Exception:

Implementing take using foldr

匆匆过客 提交于 2019-11-28 13:33:48
This is my take version using foldr : myTake n list = foldr step [] list where step x y | (length y) < n = x : y | otherwise = y main = do print $ myTake 2 [1,2,3,4] The output is not what I expect: [3,4] I then tried to debug by inserting the length of y into itself and the result was: [3,2,1,0] I don't understand why the lengths are inserted in decreasing order. Perhaps something obvious I missed? If you want to implement take using foldr you need to simulate traversing the list from left to right. The point is to make the folding function depend on an extra argument which encodes the logic

RxJava2 observable take throws UndeliverableException

橙三吉。 提交于 2019-11-27 20:04:06
问题 As I understand RxJava2 values.take(1) creates another Observable that contains only one element from the original Observable. Which MUST NOT throw an exception as it is filtered out by the effect of take(1) as it's happened second. as in the following code snippet Observable<Integer> values = Observable.create(o -> { o.onNext(1); o.onError(new Exception("Oops")); }); values.take(1) .subscribe( System.out::println, e -> System.out.println("Error: " + e.getMessage()), () -> System.out.println(