Skip to content

Instantly share code, notes, and snippets.

@peterhil
Forked from 140bytes/LICENSE.txt
Created May 23, 2011 21:46
Show Gist options
  • Save peterhil/987688 to your computer and use it in GitHub Desktop.
Save peterhil/987688 to your computer and use it in GitHub Desktop.
140byt.es -- Partial function application

140byt.es

A tweet-sized, fork-to-play, community-curated collection of JavaScript.

How to play

  1. Click the Fork button above to fork this gist.
  2. Modify all the files to according to the rules below.
  3. Save your entry and tweet it up!

Keep in mind that thanks to the awesome sensibilities of the GitHub team, gists are just repos. So feel free to clone yours and work locally for a more comfortable environment, and to allow commit messages.

Rules

All entries must exist in an index.js file, whose contents are

  1. an assignable, valid Javascript expression, that
  2. contains no more than 140 bytes, and
  3. does not leak to the global scope.

All entries must also be licensed under the WTFPL or equally permissive license.

For more information

The 140byt.es site hasn't launched yet, but for now follow @140bytes on Twitter.

To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.

140byt.es is brought to you by Jed Schmidt. It was inspired by work from Thomas Fuchs and Dustin Diaz.

function(){
var s=[].slice,
a=s.call(arguments),
f=a.shift();
return function(){
return f.apply(null,a.concat(s.call(arguments)));
};
}
function(){var s=[].slice,a=s.call(arguments),f=a.shift();return function(){return f.apply(null,a.concat(s.call(arguments)));};}
Copyright (c) 2011 Peter Hillerström, http://peter.vasb.fi/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "140bytes-peterhil-partial",
"description": "From Wikipedia: Partial application (or partial function application) refers to the process of fixing a number of arguments to a function, producing another function of smaller arity.",
"keywords": [
"functional",
"partial application",
"partial"
]
}
@minikomi
Copy link

Could you use s=[].prototype.slice to save a few chars?

@peterhil
Copy link
Author

peterhil commented Oct 5, 2011

@minikomi first I thought that wouldn't work, but it seems you can do s=[].slice and then s.call([3,4,5,6],1,3), which returns [4, 5].

@minikomi
Copy link

minikomi commented Oct 5, 2011

Even shorter :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment