Skip to content

Instantly share code, notes, and snippets.

@tylerlrhodes
Created July 8, 2018 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerlrhodes/921f6bf07919f555b0e158d5912f281d to your computer and use it in GitHub Desktop.
Save tylerlrhodes/921f6bf07919f555b0e158d5912f281d to your computer and use it in GitHub Desktop.
Demo of higher order function in c#
using System;
using System.Collections.Generic;
namespace HigherOrderProceduresDemo
{
class Program
{
static void Map(IEnumerable<int> list, Action<int> fn)
{
foreach (var item in list)
fn(item);
}
static void Main(string[] args)
{
void PrintTimes2(int a) => Console.WriteLine((a * 2).ToString());
var list = new List<int>()
{
1,
2,
3,
4,
5
};
Map(list, PrintTimes2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment