Skip to content

Instantly share code, notes, and snippets.

View robotlolita's full-sized avatar
🐴
everything happens so much oh no

Quil robotlolita

🐴
everything happens so much oh no
View GitHub Profile
/*
[DESAFIO / LANGUAGE WAR] Implemente um programa na sua linguagem favorita onde o usuário digita um número x, e o programa calcula o somatório dos x primeiros números pares da sequência fibonacci, e imprime a soma dos algarismos desse número.
Por exemplo, quando x = 5, a resposta é 17, pois:
1. A sequência fibonacci é 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,...
2. Os 5 primeiros números pares são 0, 2, 8 e 34, 144.
3. O somatório disso é 188.
4. Somando os algarismos, 1+8+8 = 17
function fun(yes) {
return yes? { foo: 'hello'
, bar: false
, quux: 10
}
: /* otherwise */ { foo: 'hey'
, bar: true
, quux: 20
}
(data "title" "My Story")
(data "author" "Mortchek")
(start-page "foo")
(page "foo"
(text "You are in a place.\n")
(choice (go "bar") "Do a thing!\n")
(choice (go "baz") "Do a different thing!\n")
(choice (give "sword") "Pick up a sword!\n")
(choice (give "shield") "Pick up a shield!\n")
function last(xs){ return xs[xs.length - 1] }
function split(predicate, xs) {
return reduce( xs
, function(rv, x, i) { return predicate(x, i)? rv.concat([[x]])
: /* otherwise */ (last(rv).push(x), rv) }
, [[ ]]) }
function splitEvery(n, xs) { return split(function(x, i){ return i > 0 && i % n == 0 }, xs) }
@robotlolita
robotlolita / 4jC1MwiM
Created April 29, 2012 15:57 — forked from anonymous/4jC1MwiM
a guest on Apr 29th, 2012 - pastebin.com/4jC1MwiM
var p1 = getMetadata(key, EPID)
var p2 = getStreams(key, EPID)
var p3 = Promise.make().waitFor(p1, p2).bind(p1, p2)
.ok( function(metadata, streams) { doSomething(metadata.value, streams.value) })
.failed(function(metadata, streams) { doStomethingElse(metadata.value, streams.value) })
.done( function(metadata, streams) { next() })
Can2D.prototype.C_Error = function(msg, fileName, lineNumber){
var e = Error.call(this, msg, filename, lineNumber)
e.name = 'C_Error'
return e
}
Can2D.prototype.C_Error.prototype = Object.create(Error.prototype)
Can2D.prototype.C_Error = function(msg, fileName, lineNumber){
return Error("Can2D: "+msg, fileName,lineNumber);
}
Can2D.prototype.CError.prototype = Error.prototype;
@robotlolita
robotlolita / gist:1975681
Created March 5, 2012 00:44 — forked from koistya/gist:1975645
Named parameters application of a function
/**
* Applies a set of named arguments to a `func`.
*
* Example: var f = function(x, y, z) { return x * (y - z); };
* namedApply(f, {x: 1, y: 2, z: 3});
*
* @param f {Function} A function to invoke.
* @param args {Object} A collection of named arguments.
* @return {Function} A new function with partially applied named arguments.
*/
void function(root){
var Point = boo.Base.derive({
init:
function(x, y) {
this.x = x
this.y = y
return this }
, fromPoint:
@robotlolita
robotlolita / non-minified.js
Last active September 28, 2015 08:28 — forked from Raynos/real-easy.js
pub sub
var pubsub = {
// A map of event names to the listeners attached to it.
// :: { "String" -> [Function] }
events: { }
// Notifies all the listeners of an event
// :: String, a... -> Undefined
, pub: function(event) {
var events = this.events[event] || []
var args = arguments