This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Retrieves the home page of a project in PyPI, and opens that homepage in your default browser. | |
| # This makes use of the PyPI JSON API: https://wiki.python.org/moin/PyPIJSON | |
| function pypi_homepage() { curl -sL http://pypi.python.org/pypi/$1/json | \ | |
| python -c "from __future__ import print_function;import json;import fileinput;\ | |
| blob=json.loads(' '.join([x for x in fileinput.input()]));print(blob['info']['home_page'])"| xargs open ;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implicit class Factorial(val n: Int) extends AnyVal{ | |
| def `!`: BigInt = n match { | |
| case _ if n < 0 => throw new IllegalArgumentException() | |
| case 0 => 1L | |
| case _ => (1 to n).foldLeft(1L)(_*_) | |
| } | |
| } | |
| defined class Factorial | |
| @ 5! |
OlderNewer