Skip to content
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

Implemented constantly in functoolz #318

Closed
wants to merge 4 commits into from

Conversation

caioaao
Copy link

@caioaao caioaao commented Jul 1, 2016

Usage:

>>> f = constantly(42)
>>> f(any, parameters, here=80)
42

Examples in other languages:

Caio Oliveira added 4 commits July 1, 2016 18:11
Usage:

```python
>>> f = constantly(42)
>>> f(any, parameters, here=80)
42
```

Examples in other languages:
- [clojure's `constantly`](https://clojuredocs.org/clojure.core/constantly)
- [haskell's `const`](http://hackage.haskell.org/package/base-4.9.0.0/docs/Prelude.html#v:const)
- [elm's `always`](http://package.elm-lang.org/packages/elm-lang/core/2.0.1/Basics#always)
Didn't knew `doctest` was running 😓
@llllllllll
Copy link
Contributor

This has already been discussed and rejected: #283

@caioaao
Copy link
Author

caioaao commented Jul 4, 2016

Hm, didn't saw that, my bad. But still, I don't agree (see this stackoverflow answer).
Also, I'm coming back from clojure, and constantly is also somewhat redundant ((fn [& args] x) would have the same effect as (constantly x)), but adds readability to the code when used. In python, writting constantly(x) instead lambda *args, **kwargs: x makes the code clearer and smaller.
About not feeling it's a part of toolz: a function like this one is perfect for an API that makes heavy use of higher order functions.
PS: can't figure out why it's not passing CI tests 😓

@caioaao
Copy link
Author

caioaao commented Jun 12, 2017

closing as it's stalled for over a year

@caioaao caioaao closed this Jun 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants