@garethheyes [question] (https://twitter.com/garethheyes/status/248797836307734528)
let call = Function.prototype.call
| /* | |
| 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; |
| 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; |
| 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);} | |
| } |
| ### Control structures ### | |
| If=si | |
| Else=en_caso_contrario | |
| Procedure=aprende_procedimiento | |
| Repeat=repite | |
| RepeatWhile=repite_mientras | |
| Return=regresar | |
| Break=truncar | |
| End=fin |
| (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]); |
| 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] |
@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, ...); |
| {- This is mine -} | |
| data Symbol = Symbol { id :: Int | |
| , str :: String | |
| } | |
| data Program = Program { classes :: Classes} | |
| data Class_ = Class_ { name :: Symbol | |
| , parent :: Symbol |
| class SymbolTable { | |
| private Stack tbl; | |
| public SymbolTable() { tbl = new Stack();} | |
| public void enterScope() { tbl.push(new Hashtable());} | |
| public void exitScope() { | |
| if (tbl.empty()) { Utilities.fatalError("existScope: can't remove scope from an empty symbol table.");} | |
| tbl.pop(); |