Geeks With Blogs
AngelEyes on .Net Tips, tricks and WTFs about Asp .Net, SQL Server and the likes.

This is long overdo... Just a short and simple example of Partial Function Application.


For some good explanations, which also include the difference between Currying and Partial Function Application, check out:

and also this answer on stackoverflow:


And here is the example, taken from real code:


        internal void Addfile(string parentDirName, string fileName, long size)


            AddElement(parentDirName, fileName, (name, parent) => new File(name, size, parent));



        public void AddDir(string parentDirName, string dirName)


            AddElement(parentDirName, dirName, (name, parent) => new Directory(dirName, parent));



        private void AddElement(string parentDirName, string name,

                                Func<stringFileSystemElementFileSystemElement> elementCreator)


            ValidateFileNames(parentDirName, name);

            var parent = (Directory)_index[parentDirName];

            FileSystemElement element = elementCreator(name, parent);


            _index.Add(name, element);


Posted on Thursday, September 27, 2012 11:20 AM | Back to top

Comments on this post: Partial Function Application

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © AngelEyes | Powered by: