These are chat archives for Ruhrpottpatriot/GW2.NET

Dec 2015
Steven Liekens
Dec 29 2015 14:35
I still don't understand why you don't Take(200) in a loop
Steven Liekens
Dec 29 2015 15:03
This message was deleted
List<List<int>> pages = new List<List<int>>();
List<int> batch;
    batch = new List<int>(identifiers.Take(200));
    if (batch.Count != 0)
} while (batch.Count != 0);
Steven Liekens
Dec 29 2015 15:09
I don't know how you can optimize that
I'm not sure if that's how Take actually works
well it isn't
Steven Liekens
Dec 29 2015 15:17
okay I'm starting to see why this is complicated
public static IEnumerable<IEnumerable<T>> Batch<T>(
        this IEnumerable<T> source, int size)
    T[] bucket = null;
    var count = 0;

    foreach (var item in source)
       if (bucket == null)
           bucket = new T[size];

       bucket[count++] = item;

       if (count != size)                

       yield return bucket.Select(x => x);

       bucket = null;
       count = 0;

    // Return the last bucket with all remaining elements
    if (bucket != null && count > 0)            
        yield return bucket.Take(count);            
usage: identifiers.Batch(200)
Steven Liekens
Dec 29 2015 21:41
ah man I'm so lost trying to write a simple console app using the new project structure
Steven Liekens
Dec 29 2015 21:51
I'm so clueless
nuget is inserting dependencies in all the wrong places
and then I have to fix it manually in project.json
like how do I pull in System.Environment in a dnxcore50 project?
the class seems to live in a package with id System.Runtime.Extensions
but package management is so weird now