4 ms·
I have 3 invites. First people to answer these questions correctly gets one (only answer one question): * What is the integral of "x + 2"? * How would you imp
by jlongster 14y ago
I have 3 invites. First people to answer these questions correctly gets one (only answer one question):
* What is the integral of "x + 2"?
* How would you implement coroutines with continuations? (Just a very brief description is fine) (edit, if nobody answers this in a few min I'll just invite people)
* What is memoization?
- imkevinxu 14y agox^2/2 + 2x + C
- danabramov 14y agoIn CoffeeScipt-flavored pseudocode, I'd say memoize (f): -> cache = { } () -> h = hash arguments cache [h] ? (cache [h] = (f arguments)) And my email would be my username at most popular email service dot com.
- jlongster 14y agoI don't know CoffeeScript too well, but reading as pseudo-code looks good. What email do you want me to use?
- danabramov 14y agoJust added-- My email would be my username at most popular email service dot com. Thanks.
- jlongster 14y agosent!
- danabramov 14y agoJust received it, thank you.
- rmcooke 14y ago1/2(x^2) + 2x + c
- jlongster 14y agoYou replied 3rd and this was already answered, but I don't think anyone is going to answer the continuation question. So I'll give it to you. What email do you want?
- PizzaManBear 14y agomemoization, basically remember the results of methods that have a particular parameter values. so it does not actually execute the method it retrieves the remembered value
- georgemcbay 14y agoIOW, memoization is a pretentious way of saying result caching.
- jlongster 14y agoI still have 1 invite so if you give me your email I'll give it to you.
- deleted 14y ago[deleted]
- deleted 14y ago[deleted]
- judofyr 14y agoYou can implement coroutines with continuations with two functions: def resume callcc do |cc| $current = self @caller = cc @resumer.call end end def self.yield callcc do |cc| $current.resumer = cc $current.caller.call(cc) end end `resume` (on a coro) will store what coroutine we're entering (globally) and the caller-continuation (so we know where to go to after Coro.yield). It will then invoke the `resumer`-continuation. `Coro.yield` will store the `resumer`-continuation on the coro (so we know where to go to after `.resume`). You need something to kick it off though. The simplest way is probably to use `(@resumer || @code).call`.
- jlongster 14y agoNice! I've already given my invites away though, sorry :(
- deleted 14y ago[deleted]