private List <string> Parse(string path) => path.Split('/') .Where(p => p != "." && !string.IsNullOrEmpty(p)) .Aggregate(ConsList.Empty <string>(), (parts, p) => p == ".." && parts.Count > 0 ? parts.Tail : parts.Cons(p)) .Reverse() .ToList();
private static IEnumerable <IConsList <A> > RenderPermutations <A>(IEnumerable <A> seq, int?rd) { var array = seq.AsArray(); var len = array.Length; var r = rd ?? array.Length; if (r > len) { throw new ArgumentException("Can't take subsequence longer than entire set"); } if (r == 0 || len == 0) { yield return(ConsList.Empty <A>()); yield break; } if (r == 1) { foreach (var item in array) { yield return(ConsList.Empty <A>().Cons(item)); } yield break; } foreach (var i in Enumerable.Range(0, array.Length)) { var sublist = array.ExceptAt(i); foreach (var subseq in RenderPermutations(sublist, r - 1)) { yield return(subseq.Cons(array[i])); } } }
/// <summary> /// Return all of the type parameters of enclosing classes and the class itself, or an empty sequence when given null. /// </summary> /// <param name="declaredType">a named type whose type parameters are to be returned</param> /// <returns></returns> internal static IEnumerable <TypeParameterSymbol> AllTypeParameters(this NamedTypeSymbol declaredType) { return(declaredType == null ? ConsList.Empty <TypeParameterSymbol>() : AllTypeParameters(declaredType.ContainingType).Concat(declaredType.TypeParameters.AsEnumerable())); }