-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
This issue describes how to implement the functional tools in Python concept docs.
You can find the related concept exercise issue here
If you have not yet contributed to concept documents, this issue will require some upfront reading to give you the needed background knowledge.
✅ Getting started
Please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time.
General Contributing Docs:
- Contributing to Exercism | Exercism and GitHub | - Contributor Pull Request Guide
- What are those Weird Task Tags about?
- Exercism Formatting and Style Guide
- Exercism Markdown Specification
- Reputation
Documents on Language Tracks and Concepts:
🎯 Goal
These concept docs are meant to teach an understanding/use of core functional tools (e.g, map(), filter(), and functools.reduce() in Python.
💡 Learning objectives
- Understand/use the
built-in map()function.- constructing a
lambdaor callback function used as the argument. - comparisons to
set,dictorlistcomprehensions - when and when not to use - considering performance & readability
- constructing a
- Understand/use the
built-in filter()function.- constructing a
lambdaor callback function used as the argument. - comparisons to
set,dictorlistcomprehensions - when and when not to use - considering performance & readability
- constructing a
- Understand/use the
functools.reduce()function- constructing a
lambdaor callback function used as the argument. - using
initializeras a "first call" or to guard against TypeErrors when the passediterableis empty. - comparisons to
sum(),min(),max(),any(),all(),math.prod()and tointertools.accumulate() - when and when not to use - considering performance & readability
- constructing a
🚫 Out of scope
Concepts & Subjects that are Out of Scope (click to open)
comprehensionscomprehensionsinlambdasmap(),filter()orfunctools.reduce()within acomprehensionfunctoolsbeyondfunctools.reduce()(this will get its own exercise)generatorsmap(),filter()orfunctools.reduce()within agenerator expression- using an
assignment expressionor "walrus" operator (:=) in alambda(walrus in general is OK if it is explained, just not inside a lambda)
🤔 Concepts
Concepts & Related Concepts Covered (click to open)
- functional tools in python
built-insany()&all()sum()min()&max()map()filter()
functools.reduce()itertools.accumulate()
↩️ Prerequisites
These are the concepts/concept exercises the student should be familiar with before taking on/learning this concept.
Prereqs (click to open)
basicsboolscomparisonsdictsdict-methodsfunctionsfunction-argumentshigher-order-functionsiterationlambdaslistslist-methodsnumberssequencessetsstringsstring-methodstuples
📚 Resources to refer to
Resources (click to open)
- Python Docs: Defining Functions
- Python Docs Tutorial: Lambda Expressions
- Functions as Objects in Python
- Composing Programs: Higher-Order Functions
- built-ins: Python Docs
itertools.accumulate()functools.reduce()- Real Python: Functional Programming in Python: When and How to Use it
- Real Python : Python's map(): Processing Iterables Without a Loop
- Real Python: Python's reduce(): From Functional to Pythonic Style
Additional Articles (click to open)
📁 Files to Be Created
File Detail for this Exercise (click to collapse)
|
Please see the following for more details on these files: concepts
|
🎶 Implementation Notes
- Example code should only use syntax & concepts introduced within these docs or one of the prerequisite concept exercises or documents. Where possible, please use REPL formatting, unless you are demonstrating pseudo code or a long code block.
Please do not use syntax not previously covered in prerequisite topics or exercises. Please also follow PEP8 guidelines. - Our markdown and JSON files are checked against prettier . We recommend setting prettier up locally and running it prior to submitting your PR to avoid any CI errors.
🆘 Next Steps & Getting Help
If you'd like to work on this issue, comment saying "I'd like to work on this"(there is no real need to wait for a response, just go ahead, we'll assign you and put a[claimed]label on the issue).- If you have any questions while implementing, please post the questions as comments in here, or contact one of the maintainers on our Slack channel.