@garethheyes [question] (https://twitter.com/garethheyes/status/248797836307734528)
let call = Function.prototype.call
| Datatype -> | |
| class Datatype_class : public tree_node | |
| constructor_of_Datatype -> | |
| class constructor_class : public Datatype_class { | |
| ... | |
| constructor_class(...) | |
| Datatype constructor( par1, par2, ... ) { | |
| return new constructor_class(par1, par2, ...); |
@garethheyes [question] (https://twitter.com/garethheyes/status/248797836307734528)
let call = Function.prototype.call
| import System.Environment | |
| type Vec = [Int] -- (Int,Int,Int,Int,Int,Int) | |
| data UnaSol = UnaSol { values :: [Vec], rest :: Vec} deriving (Show) | |
| type Sol = [UnaSol] | |
| beta :: Vec -> [Int] -> Sol | |
| beta t [] = [UnaSol [] t] |
| (function(carrier){ | |
| var hasOwn = Object.prototype.hasOwnProperty; | |
| var slice = Array.prototype.slice; | |
| function extend(obj,src){ | |
| for (var p in src){ | |
| if (hasOwn.call(src,p)) { | |
| if (p in obj && typeof obj[p] === 'object' && obj[p]) { | |
| extend(obj[p],src[p]); |
| ### Control structures ### | |
| If=si | |
| Else=en_caso_contrario | |
| Procedure=aprende_procedimiento | |
| Repeat=repite | |
| RepeatWhile=repite_mientras | |
| Return=regresar | |
| Break=truncar | |
| End=fin |
| function ImTheLeche(legoCreator) { | |
| return function(){ | |
| return function(protopato) { | |
| legoCreator.gn = legoCreator.prototype = | |
| Object.create(protopato,{constructor:{value:legoCreator}}); | |
| return {init:function(){ | |
| var fakeMVCfever = | |
| Object.create(legoCreator.gn,{constructor:{value:this.init}}); | |
| return legoCreator.apply(fakeMVCfever,arguments);} | |
| } |
| var one = function(arg){return 'Hola ' + arg;}; | |
| var two = function(arg){return 'Adios ' + arg;}; | |
| alert(one('Otoño')); | |
| alert(two('Verano')); | |
| //Siglos después descubrimos que hay que preprocesar el argumento :) | |
| Function.prototype.makeCoat = function() { | |
| var service = this; |
| /* | |
| http://twitter.com/#!/bga_/status/116861871423885312 | |
| */ | |
| Object.prototype.thunk = function(name, calc) { | |
| Object.defineProperty(this,name,{get: function() { | |
| var ret = calc(); | |
| delete this[name] // memo result | |
| this[name] = ret; |
| /* | |
| RECUENTO DE VOTOS PARA | |
| http://www.meetup.com/madridjs/pages/Votaci%F3n_para_%22Yo_tambi%E9n_quiero_una_birra%22/ | |
| Abre la consola, pega el siguiente código en ella | |
| y ejecuta el siguiente código :) | |
| Verficado en Firefox a las 14:46 del 2011-09-01 | |
| */ |
| function getMax(a,b) { | |
| var r = Math.sqrt(a-b); | |
| if (isNaN(r)) return b; | |
| else return a; | |
| } |