/// <summary> /// Computes the standard deviation of the given values. /// </summary> public static float StandardDeviation(this List<float> values) { if (values.Count == 0) return 0; float avg = values.Average(); // Calculates sum((xi - avg)²) float sum = values.ConvertAll(val => (float)Math.Pow(val - avg, 2)).Sum(); return (float)Math.Sqrt(sum / values.Count); }
public static bool WaitAll(this List<IAsyncResult> asyncResults, TimeSpan timeout) { var waitHandles = asyncResults.ConvertAll(x => x.AsyncWaitHandle); return WaitAll(waitHandles.ToArray(), (int)timeout.TotalMilliseconds); }
public static string ToCodeString(this List<string> list) { return "new string[] { " + string.Join(", ", list.ConvertAll((s) => '"' + s + '"')) + " }"; }
public static List<SquawkListItemViewModel> ConvertToSquawkItemViewModel(this List<Squawk> squawkList) { return squawkList.ConvertAll(x => new SquawkListItemViewModel() { Id = x.Id, Subject = x.Subject, TailNumber = x.Aircraft.RegistrationNumber, PostedBy = x.PostedBy.FirstName + " " + x.PostedBy.LastName, PostedOn = x.PostedOn, Status = x.Status }); }
/// <summary> /// Convert list of points to list of xyz's /// </summary> /// <param name="list">The list to convert</param> /// <returns></returns> public static List<XYZ> ToXyzs(this List<Autodesk.DesignScript.Geometry.Point> list) { return list.ConvertAll((x) => new XYZ(x.X, x.Y, x.Z)); }
/// <summary> /// Convert list of points to list of xyz's /// </summary> /// <param name="list">The list to convert</param> /// <returns></returns> public static List<Autodesk.DesignScript.Geometry.Point> ToPoints(this List<XYZ> list) { return list.ConvertAll((x) => Autodesk.DesignScript.Geometry.Point.ByCoordinates(x.X, x.Y, x.Z)); }
public static List<XYZ> ToXyzs(this List<Autodesk.DesignScript.Geometry.Point> list, bool convertUnits = true) { return list.ConvertAll((x) => x.ToXyz(convertUnits)); }
public static List<DC.PlayerMove> ToDataContract(this List<VM.PlayerMove> moves) { if (moves == null) return new List<DC.PlayerMove>(); return moves.ConvertAll(ToDataContract); }
public static List<TeamListView> ToViewModel(this List<Team> teams) { return teams.ConvertAll(team => team.ConvertTo<TeamListView>()); }
public static List<ObjectItem> GetObjects(this List<BankItemRecord> items) { return items.ConvertAll<ObjectItem>(x => new ObjectItem(63, x.GID, x.GetEffects(), x.UID, x.Quantity)); }
public static Hatch CreateHatch(this List<Point3d> pts) { return CreateHatch(pts.ConvertAll(Point3dExtensions.Convert2d)); }
public static List<ReservationViewModel> ConvertToReservationViewModel(this List<Reservation> reservationList) { return reservationList.ConvertAll(x => new ReservationViewModel() { Id = x.Id, MemberId = x.MemberId, Member = x.Member, AircraftId = x.AircraftId, Aircraft = x.Aircraft, StartDate = x.StartDate, StartTime = x.StartDate.ToString("HH:mm"), EndDate = x.EndDate, EndTime = x.EndDate.ToString("HH:mm") }); }
public static List<VM.PlayerMove> ToViewModel(this List<DC.PlayerMove> moves) { if(moves == null) return new List<VM.PlayerMove>(); return moves.ConvertAll(ToViewModel); }