Skip to content

Instantly share code, notes, and snippets.

@jmurowaniecki
Last active August 26, 2016 17:22
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 jmurowaniecki/62b207fade55ac46e416bf1a40e6bcd2 to your computer and use it in GitHub Desktop.
Save jmurowaniecki/62b207fade55ac46e416bf1a40e6bcd2 to your computer and use it in GitHub Desktop.
Exemplo de uso de caractere especial em Javascript
// jshint esversion: 6, laxbreak: true
function λ() {
'use strict';
var $$$=[], r,i,p=performance;
for(let _ of arguments) $$$.push(_);
i=p.now();
r=$$$.shift().apply(r,$$$);
console.log(p.now()-i);
return r;
}
// A resposta segundo Douglas Adams
λ(function F(u,c,k) {
return c*u + (!k||k<6 ? F(u,c,(k || 0) + 1) : 0);
}, 2, 3);
// A resposta segundo Leonardo Fibonacci
λ(function φ(F,i,b) {
F = F || 1;
i = i || 0x29a;
b = b || 01232;
return (typeof F !== typeof []
? φ([F],i,b)
: ((F.length < i && F.length-1 < b)
?(F.push(F[F.length - 1] + (F[F.length - 2] || 0)), φ(F,i,b))
: F));
}, 1, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment