-
Notifications
You must be signed in to change notification settings - Fork 0
hw6MapFilterFold #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
hw6MapFilterFold #11
Conversation
| { | ||
| public static class Functions<T> | ||
| { | ||
| public static List<T> Map(List<T> list, Func<T, T> function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не обязательно тип параметра должен совпадать с типом результата. Functions.Map(list, x => x.ToString()) тоже можно и часто используется.
|
|
||
| namespace hw6MapFilterFold | ||
| { | ||
| public static class Functions<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Параметр-тип самому классу не нужен, у каждого метода есть свои
| { | ||
| public static List<T> Map(List<T> list, Func<T, T> function) | ||
| { | ||
| int count = list.Count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не понадобилось вроде :)
| return resultList; | ||
| } | ||
|
|
||
| public static List<T> Filter(List<T> list, Func<T, bool> function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И надо комментарии ко всему
| return returnList; | ||
| } | ||
|
|
||
| public static T Fold(List<T> list, T startValue,Func<T, T, T> function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут тоже с типами всё сложнее :)
yurii-litvinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| public void FilterTest() | ||
| { | ||
| var resultList1 = new List<int>() { 2 }; | ||
| var list1 = Functions.Filter(listInt, y => y % 2 == 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var list1 = Functions.Filter(listInt, y => y % 2 == 0 ); | |
| var list1 = Functions.Filter(listInt, y => y % 2 == 0 ); |
| /// <param name="startValue">начальное значение</param> | ||
| /// <param name="function">функция</param> | ||
| /// <returns>накопленное значение</returns> | ||
| public static TResult Fold<TValue, TResult>(List<TValue> list, TResult startValue,Func<TResult, TValue, TResult> function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public static TResult Fold<TValue, TResult>(List<TValue> list, TResult startValue,Func<TResult, TValue, TResult> function) | |
| public static TResult Fold<TValue, TResult>(List<TValue> list, TResult startValue, Func<TResult, TValue, TResult> function) |
No description provided.