by jlongster · 13y ago · 0 comments
* 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?
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`.
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.What email do you want me to use?
My email would be my username at most popular email service dot com.
Thanks.
So I'll give it to you. What email do you want?