Files
TheDeclineOfWarriors/Assets/FishNet/CodeGenerating/cecil-0.11.4/rocks/Mono.Cecil.Rocks/Functional.cs
T
2026-03-30 20:11:57 +07:00

41 lines
1013 B
C#

//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
using System.Collections.Generic;
namespace MonoFN.Cecil.Rocks
{
internal static class Functional
{
public static Func<A, R> Y<A, R>(Func<Func<A, R>, Func<A, R>> f)
{
Func<A, R> g = null;
g = f(a => g(a));
return g;
}
public static IEnumerable<TSource> Prepend<TSource>(this IEnumerable<TSource> source, TSource element)
{
if (source == null)
throw new ArgumentNullException("source");
return PrependIterator(source, element);
}
private static IEnumerable<TSource> PrependIterator<TSource>(IEnumerable<TSource> source, TSource element)
{
yield return element;
foreach (TSource item in source)
yield return item;
}
}
}