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
/** Consider the interface
interface Mappable<A> {
map: (A → B) → Mappable<B>
}
*/
function Identity(value) {
@robotlolita
robotlolita / ConcatChurch.purr
Last active August 29, 2015 14:17
Concatenative stack-based language with church encoded data structures in Purr.
module ConcatChurch is
import Prelude
# -- Helpers ---------------------------------------------------------
export $a get => match $a with
| $a' :: _ => $a'
end
export $a to-number => $a depth-start: 0
where
var models = [{
name: 'Jonathan',
location: 'Earth'
}, {
name: 'Joe',
location: 'Mars'
}]
var ps = models.map(function(model) {
function id(a) {
return a
}
function compose(f, g){ return function(x) {
return f(g(x))
}}
function partial(f, x) {
return function(y) {
function pipeline(fs, val, done) {
if (fs.length === 0) done(null, val)
else fs[0](val, function(err, val) {
if (err) done(err)
else pipeline(fs.slice(1), val, done)
})
}
pipeline([
asyncFunctionOne,
@robotlolita
robotlolita / a.js
Last active August 29, 2015 14:24 — forked from notblizzard/a.js
exports.commands = {
mb: 'musicbox',
musicbox: function (target, room, user) {
if (!this.canBroadcast()) return;
var parts = target.split(',');
if (!target) return this.sendReply("/musicbox link, link, link - parses it to be in a music box");
var parsedParts = parts.map(parse);
Promise.all(parsedParts).then(function(parts) {
var str = parts.join('');
this.sendReply('str is ' + str);
/**
* Object.keys(object) -> Array of String
*
* List the keys that belongs only to the given object.
**/
(function() {
function list_keys(object) {
var prop
, keys = [];
/**
* preload(urls[, wait=10][, callback])
* - urls (Array): a list of all image urls to preload
* - delay (Number): how much time to wait for an image before
* flagging it as unreachable, in seconds.
* - callback (Function): optional function to call after all images
* are preloaded.
**/
function preload(urls, wait, callback) {
var timer_id; // id of the last timer event
// The outrageous totally awesomely unoptimized and hard way of doing
// the stuff :D
(function() {
var c, list
, letters = {}
, str = "ah, yes, for all the letters, you'll need"
+ "a loop... i read it wrong."
;
str.replace(/\s|\S/g, function(match) {
// --[ main.js ]---------------------------------------------------------------
require('A.js', function cba() { /* A.js was loaded */ });
// --[ A.js ]------------------------------------------------------------------
require('B.js', function cbb() { /* B.js was loaded */ });
// --[ B.js ]------------------------------------------------------------------
/* dummy file */
// ----------------------------------------------------------------------------