Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How should I do this assignment?

Name: m an idiot 2009-02-16 16:46

I think C++ would be the best to use, but I don't have any clue on how to start this assignment.
http://www.cs.ecu.edu/~gopal/os1/ass1.pdf
It's due today, which I've no illusions I can do, I still need to do it. Too many tests at the same time have stopped me from getting an earlier start on it, and its been some time since I've programmed.
I just want to know how I should start this, including variables, methods, and classes. Any suggestions would be appreciated.

Name: Anonymous 2009-02-17 0:16

>>1
Here you go, bro.

-module(ass1).
-export([sum/1, add/3]).

sum(List) -> sum(0, List).    

sum(N, []) -> sum_collect(N);
sum(N, [A]) -> sum(N, [A,0]);              
sum(N, [A|[B|List]]) -> spawn(ass1, add, [self(), A, B]), sum(N+1, List).

sum_collect(0) -> 0;
sum_collect(1) -> receive Result -> Result end;
sum_collect(N) ->
    receive Result1 ->
        receive Result2 ->
            spawn(ass1, add, [self(), Result1, Result2]),
            sum_collect(N-1)
        end
    end.

add(Coordinator,A,B) -> Coordinator ! A+B.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List