Questions tagged [take]

Take is a common keyword or function name used to return a given number of elements, usually contiguously and from the beginning of a collection. Only use this tag for the take keyword or function name; usage such as "take a picture/screenshot" is out of scope.

Take functions usually only require two pieces of information: the number of elements to be returned from the sequence, and the sequence itself.

If take is a method in a particular library or language, it is called on the object and would only require the number parameter.

This concept is found in many languages and libraries, some of which are listed below.

Reference

142 questions
4
votes
4 answers

Issues taking picture with Android (Vertical Camera | Portrait)

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…
ephramd
  • 561
  • 2
  • 15
  • 41
4
votes
2 answers

How does Ruby enumerator terminate iteration?

Friends, please I need help with this explanation: In the Ruby code below, what condition termites the loop do? It's supposed to be an infinite loop, but, how does it terminate? # Ruby code fib = Enumerator.new do |y| a = b = 1 loop do y <<…
Sunday Ezeilo
  • 175
  • 1
  • 10
4
votes
1 answer

Haskell take and drop at the same time

I was wondering how can I achieve: Taking the first n characters of a string then ++(concatenating them with) drop these first n and take the next n and so on (without cutting words). I have tried function composition and $ but the only thing I…
Dimitar
  • 4,402
  • 4
  • 31
  • 47
4
votes
3 answers

Understanding the basic principle of LINQ's Where/Take

I have a List myList. I want to take the first 10 items in this list that match some criteria (let's say .Contains("a"), for example). I have: Var results = myList.Where(o=>o.Contains("a")).Take(10); Which works fine, but has LINQ performed…
user1017882
4
votes
4 answers

How do I get the last 5 rows of a datatable?

How do I get the last 5 rows of a datatable? I tried something like this: var Long_bottom = LongSlection.Last(5); Where LongSlection is a DataRow. But I had an error, any idea?
francops henri
  • 507
  • 3
  • 17
  • 29
3
votes
1 answer

Entity framework joins

I'm using the entity framework 4.0 and I'm having some issues with the syntax of my query. I'm trying to join 2 tables and pass a parameter to find the value at the same time.I would like find all of the products in table 2 by finding the…
user686483
  • 1,584
  • 6
  • 18
  • 29
3
votes
2 answers

Implementing take with F# by translating ML's equivalent

I'd like to translate this ML code into F#. fun take ([], i) = [] | take (x::xs, i) = if i > 0 then x::take(xs, i-1) else []; I tried this one let rec take n i = match n,i with | [], i -> [] | x::xs, i…
prosseek
  • 182,215
  • 215
  • 566
  • 871
3
votes
1 answer

get the size of dataset after applying a filter from tf.data.Dataset

I wonder how I can get the size or the len of the dataset after applying a filter. Using tf.data.experimental.cardinality give -2, and this is not what I am looking for!! I want to know how many filtered samples exist in my dataset in order to be…
Lukas
  • 403
  • 5
  • 11
3
votes
3 answers

Bug ? Seq.take 10 works well , Seq.take 100 doesn't work

let a = [1;2;3;] for i in (a |> Seq.take 10) do Console.WriteLine(i) for i in (a |> Seq.take 100) do Console.WriteLine(i) first line works well but second line gives error : The input sequence has an insufficient number of elements. Yes , there is…
cnd
  • 32,616
  • 62
  • 183
  • 313
3
votes
1 answer

Why Pagination laravel ignores requests - skip, take

I wanted to use skip and take but pagination does not work. Why does it not work? Code: $posts = DB::table('posts') ->orderBy('id','desc') ->skip(9) ->take(3) ->paginate(3); if ($request->ajax()) { …
3
votes
1 answer

take picture using CameraBridgeViewBase on openCV

I had a Binary image. Now, How to when I will click on Button I want to take its.? Please Help me. This is my code: public class MainActivity extends Activity implements CameraBridgeViewBase.CvCameraViewListener2, Camera.PictureCallback { …
lucky
  • 43
  • 1
  • 5
3
votes
3 answers

use pagination for limited records in laravel 5.2

I am trying to use paginate method for 12 records. I need 12 results where first 6 results comes in first page and the rest 6 results in second page. I used the below code in the controller, $collection = User::take(12)->whereHas('roles',…
Oops
  • 1,373
  • 3
  • 16
  • 46
3
votes
2 answers

Using Take() to grab bytes out of a byte array, having trouble converting back to byte[] after the Take()

byte[] result = memStream.ToArray(); memStream.Close(); byte[] temp = result.Take(255); var str = System.Text.Encoding.Default.GetString(temp); The above fails on the result.Take(255); line. It says I can't convert…
MrDysprosium
  • 489
  • 9
  • 20
3
votes
2 answers

LINQ IQueryable returning same rows with skip and take

Using MVC Entity Framework I'm calling a function with AJAX that passes in skip and take parameters. [HttpGet] public async Task _ViewMore( int take, int skip) { var c = await GetContent( take, skip); return View(c) } public…
Jackmagic1
  • 83
  • 12
3
votes
2 answers

Why does reducing this lazy sequence slow down this Clojure program 20x?

I have a Clojure program that returns the sum of a lazy sequence of even Fibonacci numbers below n: (defn sum-of-even-fibonaccis-below-1 [n] (defn fib [a b] (lazy-seq (cons a (fib b (+ b a))))) (reduce + (take-while (partial >= n) (take-nth 3…
alt
  • 13,357
  • 19
  • 80
  • 120
1
2
3
9 10