News for hackers. Stuff that matters.
Re:As of today, App.net is a freemium service by jlongster on Monday February 25, 2013 @01:58PM (#5280889)
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?

Re:As of today, App.net is a freemium service by judofyr on Monday February 25, 2013 @02:38PM (#5281212)
You 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`.

Re:As of today, App.net is a freemium service by jlongster on Monday February 25, 2013 @02:57PM (#5281343)
Nice! I've already given my invites away though, sorry :(
Re:As of today, App.net is a freemium service by danabramov on Monday February 25, 2013 @02:02PM (#5280917)
In 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.
Re:As of today, App.net is a freemium service by jlongster on Monday February 25, 2013 @02:04PM (#5280930)
I don't know CoffeeScript too well, but reading as pseudo-code looks good.

What email do you want me to use?

Re:As of today, App.net is a freemium service by danabramov on Monday February 25, 2013 @02:06PM (#5280942)
Just added--

My email would be my username at most popular email service dot com.

Thanks.

Re:As of today, App.net is a freemium service by jlongster on Monday February 25, 2013 @02:18PM (#5281042)
sent!
Re:As of today, App.net is a freemium service by danabramov on Monday February 25, 2013 @02:32PM (#5281149)
Just received it, thank you.
Re:As of today, App.net is a freemium service by PizzaManBear on Monday February 25, 2013 @02:06PM (#5280938)
memoization, 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
Re:As of today, App.net is a freemium service by georgemcbay on Monday February 25, 2013 @02:12PM (#5280993)
IOW, memoization is a pretentious way of saying result caching.
Re:As of today, App.net is a freemium service by jlongster on Monday February 25, 2013 @02:19PM (#5281051)
I still have 1 invite so if you give me your email I'll give it to you.
Re:As of today, App.net is a freemium service by rmcooke on Monday February 25, 2013 @02:03PM (#5280921)
1/2(x^2) + 2x + c
Re:As of today, App.net is a freemium service by jlongster on Monday February 25, 2013 @02:10PM (#5280981)
You 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?

Re:As of today, App.net is a freemium service by ozaibi on Monday February 25, 2013 @06:14PM (#5282547)
I would love to try my luck :) Or a charity for my cause :) [email protected] [email protected] Hope it's not too much to ask :) Cheers
Re:As of today, App.net is a freemium service by rmcooke on Monday February 25, 2013 @02:28PM (#5281121)
Re:As of today, App.net is a freemium service by imkevinxu on Monday February 25, 2013 @02:02PM (#5280914)
x^2/2 + 2x + C
Re:As of today, App.net is a freemium service by jlongster on Monday February 25, 2013 @02:03PM (#5280920)
What email do you want? :D
Re:As of today, App.net is a freemium service by imkevinxu on Monday February 25, 2013 @02:07PM (#5280957)
emailed it to you