add const function
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 280
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 4
Description
I haven't found a function in toolz to replicate Haskell's const function, that creates a function that returns a constant value.
Example usage would be
def const(v):
return lambda *x, **k: v
f = const(5)
f(2) # 5
f(3.14, [1, 3], a='whatever') # 5
Unless I'm missing an existing function, would it be worthwhile to add something similar to the library?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by searching the toolz package for existing constant-function helpers and the public export pattern, then inspect the related tests. Done means a public const utility returns the captured value regardless of positional or keyword arguments, with tests covering the examples in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100