python
python copied to clipboard
[New Concept Docs]: Higher Order Functions
This issue describes how to implement the higher-order functions 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 a deeper understanding/use/creation of higher-order functions in Python.
đĄ Learning objectives
- Understand and create
higher-order functionsin Python - Create
functionsused as arguments to otherfunctions - Create
functionsthat returnfunctions - Learn about
currying - Understand and create
closures-- where an inner function has access to a variable from it's enclosing scope (the outer function) that has completed its execution. - Understand and use a simple
recursion-- where afunctioncalls itself as an argument.
đĢ Out of scope
Concepts & Subjects that are Out of Scope (click to open)
This exercise assumes an understanding of its prerequisites, so it is not necessary to go into scoping, function special attributes, function arguments, or other concepts "higher" in the syllabus "tree".
comprehensionsdecorators(these will have their own exercise)functools(this will get its own exercise)functools.wrapsgeneratorslambda,anonymous functionsmap(),filter(), andreduce()(these will get their own exercise)nonlocal&locals()global&globals()argument unpacking
đ¤ Concepts
Concepts and Related Concepts this Concept Covers (click to open)
closurescurryingfunctions,higher-order functionsfunctions as argumentsfunctions as returnsrecursion
âŠī¸ Prerequisites
These are the concepts/concept exercises the student should be familiar with before taking on/learning this concept.
Prereqs (click to open)
basicsbooleanscomparisonsdictsdict-methodsfunctionsfunction-argumentsargument unpackingiterationlistslist-methodsnumberssequencessetsstringsstring-methodstuples
đ Resources to refer to
Resources (click to open)
- Python Docs: Python Scopes and Namespaces
- Python Docs: Defining Functions
- Dan Bader: Python s Functions are First-Class
- Functions as Objects in Python
- Composing Programs: Higher-Order Functions
- Tobias Kohn: Closures in Python
- zetcode: Python Closures
- Sagnick: Python is the Haskell you Never Knew You Had: Currying
- Oreilly: Associating Parameters with a Function (Currying)
- Real Python: Thinking Recursively in Python
- Train Your Brain to Think Recursively
đ Files to Be Created
File Detail for these Concept Docs
|
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.