10 ms·
Neat! Not quite the same thing, but see also this 9-line "spreadsheet" written in Python by Raymond Hettinger: http://code.activestate.com/recipes/355045-spread
by benhoyt 13y ago
Neat! Not quite the same thing, but see also this 9-line "spreadsheet" written in Python by Raymond Hettinger: http://code.activestate.com/recipes/355045-spreadsheet/ http://code.activestate.com/recipes/355045-spreadsheet/
- draegtun 13y agoVery neat. Thought I'd have a crack at doing something similar in Rebol. Here's my attempt: Rebol [] ; Here's the beef!... the spreadsheet object spreadsheet: context [ update: func [block /local b] [ b: compose/deep block bind b self ; so action happens in object context do b ] ] ; make sheet with following cells ss: make spreadsheet [ a1: 5 a2: does [a1 * 6] a3: does [a2 * 7] ] ; simple usage example print ss/a3 ; => 210 ss/a1: 6 print ss/a3 ; => 252 ; use /update method to keep it within the objects context (needed for DOES) ss/update [a3: does [a1 + a2]] print ss/a3 ; => 42 ; and compose in variables from current context, see (a1) a1: 1000 ss/update [a3: does [a1 + (a1)]] print ss/a3 ; => 1006 You could probably do something very similar in other prototype based object languages.