Skip to content

Instantly share code, notes, and snippets.

@lagenorhynque
Last active August 16, 2019 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lagenorhynque/40f61bb9c89078b8c402ce5561536492 to your computer and use it in GitHub Desktop.
Save lagenorhynque/40f61bb9c89078b8c402ce5561536492 to your computer and use it in GitHub Desktop.
Clojure's apply vs Python's unpacking operator
$ clj
Clojure 1.10.1
user=> (defn plus [& args]
(apply + args))
#'user/plus
user=> (plus 1 2 3)
6
user=> (apply plus [1 2 3])
6
$ python
Python 3.7.3 (default, Jul 3 2019, 18:56:39)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def plus(*args):
... return sum(args)
...
>>> plus(1, 2, 3)
6
>>> plus(*[1, 2, 3])
6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment